Module Name: src Committed By: apb Date: Sat Mar 29 11:34:13 UTC 2014
Modified Files: src/sys/arch/m68k/m68k: procfs_machdep.c Log Message: procfs_getcpuinfstr's len argument contains the buffer size on entry, and the number of bytes used on return. Use the actual buffer size in a snprintf call, instead of sizeof(*buf), which is always 1. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/m68k/m68k/procfs_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/m68k/m68k/procfs_machdep.c diff -u src/sys/arch/m68k/m68k/procfs_machdep.c:1.5 src/sys/arch/m68k/m68k/procfs_machdep.c:1.6 --- src/sys/arch/m68k/m68k/procfs_machdep.c:1.5 Sat Jul 22 06:58:17 2006 +++ src/sys/arch/m68k/m68k/procfs_machdep.c Sat Mar 29 11:34:13 2014 @@ -1,7 +1,7 @@ -/* $NetBSD: procfs_machdep.c,v 1.5 2006/07/22 06:58:17 tsutsui Exp $ */ +/* $NetBSD: procfs_machdep.c,v 1.6 2014/03/29 11:34:13 apb Exp $ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.5 2006/07/22 06:58:17 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.6 2014/03/29 11:34:13 apb Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -19,8 +19,7 @@ int procfs_getcpuinfstr(char *buf, int *len) { const char *cpu, *mmu, *fpu; - - *len = 0; + int maxlen = *len; switch (cputype) { case CPU_68020: @@ -79,7 +78,7 @@ procfs_getcpuinfstr(char *buf, int *len) break; } - *len = snprintf(buf, sizeof(buf), + *len = snprintf(buf, maxlen, /* as seen in Linux 2.4.27 */ "CPU:\t\t%s\n" "MMU:\t\t%s\n"