Module Name: src Committed By: mrg Date: Thu Jul 7 08:48:34 UTC 2011
Modified Files: src/sys/arch/evbarm/gumstix: gumstix_machdep.c Log Message: fix an off by one array bounds issue, and also fix a potentially non nul-terminated string. To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/sys/arch/evbarm/gumstix/gumstix_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/evbarm/gumstix/gumstix_machdep.c diff -u src/sys/arch/evbarm/gumstix/gumstix_machdep.c:1.37 src/sys/arch/evbarm/gumstix/gumstix_machdep.c:1.38 --- src/sys/arch/evbarm/gumstix/gumstix_machdep.c:1.37 Fri Jul 1 20:39:34 2011 +++ src/sys/arch/evbarm/gumstix/gumstix_machdep.c Thu Jul 7 08:48:34 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: gumstix_machdep.c,v 1.37 2011/07/01 20:39:34 dyoung Exp $ */ +/* $NetBSD: gumstix_machdep.c,v 1.38 2011/07/07 08:48:34 mrg Exp $ */ /* * Copyright (C) 2005, 2006, 2007 WIDE Project and SOUM Corporation. * All rights reserved. @@ -222,6 +222,7 @@ BootConfig bootconfig; /* Boot config storage */ static char bootargs[MAX_BOOT_STRING]; +const size_t bootargs_len = sizeof(bootargs) - 1; /* without nul */ char *boot_args = NULL; uint32_t system_serial_high; @@ -1092,13 +1093,14 @@ consinit(); } #endif - if (j == MAX_BOOT_STRING) { + if (j == bootargs_len) { *(bootargs + j) = '\0'; continue; } if (j != 0) *(bootargs + j++) = ' '; - strncpy(bootargs + j, argv[i], MAX_BOOT_STRING - j); + strncpy(bootargs + j, argv[i], bootargs_len - j); + bootargs[bootargs_len] = '\0'; j += strlen(argv[i]); } boot_args = bootargs;