Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/evbarm/gumstix fix an off by one array bounds issue...
details: https://anonhg.NetBSD.org/src/rev/83ff1ed03b4a
branches: trunk
changeset: 767040:83ff1ed03b4a
user: mrg <mrg%NetBSD.org@localhost>
date: Thu Jul 07 08:48:34 2011 +0000
description:
fix an off by one array bounds issue, and also fix a potentially non
nul-terminated string.
diffstat:
sys/arch/evbarm/gumstix/gumstix_machdep.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diffs (34 lines):
diff -r 1b1f93af259a -r 83ff1ed03b4a sys/arch/evbarm/gumstix/gumstix_machdep.c
--- a/sys/arch/evbarm/gumstix/gumstix_machdep.c Thu Jul 07 08:47:22 2011 +0000
+++ b/sys/arch/evbarm/gumstix/gumstix_machdep.c Thu Jul 07 08:48:34 2011 +0000
@@ -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;
Home |
Main Index |
Thread Index |
Old Index