Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch avoid writing 1 byte beyond the end of the string p...



details:   https://anonhg.NetBSD.org/src/rev/ade53284df3f
branches:  trunk
changeset: 773261:ade53284df3f
user:      mrg <mrg%NetBSD.org@localhost>
date:      Mon Jan 30 04:25:14 2012 +0000

description:
avoid writing 1 byte beyond the end of the string promlib.c has given us.
instead of forcing a nul byte afterwards, KASSERT() that the final byte
already is a nul.  if there are broken proms... well, we can fix them.

this, plus one more change, allows my SS20 to boot multiuser.

diffstat:

 sys/arch/sparc/dev/ebus.c   |  6 +++---
 sys/arch/sparc/dev/sbus.c   |  6 +++---
 sys/arch/sparc64/dev/ebus.c |  6 +++---
 sys/arch/sparc64/dev/sbus.c |  6 +++---
 4 files changed, 12 insertions(+), 12 deletions(-)

diffs (108 lines):

diff -r f14e8d56e524 -r ade53284df3f sys/arch/sparc/dev/ebus.c
--- a/sys/arch/sparc/dev/ebus.c Mon Jan 30 03:28:33 2012 +0000
+++ b/sys/arch/sparc/dev/ebus.c Mon Jan 30 04:25:14 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ebus.c,v 1.33 2011/07/18 00:31:13 mrg Exp $ */
+/*     $NetBSD: ebus.c,v 1.34 2012/01/30 04:25:14 mrg Exp $ */
 
 /*
  * Copyright (c) 1999, 2000 Matthew R. Green
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ebus.c,v 1.33 2011/07/18 00:31:13 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ebus.c,v 1.34 2012/01/30 04:25:14 mrg Exp $");
 
 #if defined(DEBUG) && !defined(EBUS_DEBUG)
 #define EBUS_DEBUG
@@ -332,7 +332,7 @@
        err = prom_getprop(node, "name", 1, &n, &ea->ea_name);
        if (err != 0)
                return (err);
-       ea->ea_name[n] = '\0';
+       KASSERT(ea->ea_name[n-1] == '\0');
 
        ea->ea_node = node;
        ea->ea_bustag = bustag;
diff -r f14e8d56e524 -r ade53284df3f sys/arch/sparc/dev/sbus.c
--- a/sys/arch/sparc/dev/sbus.c Mon Jan 30 03:28:33 2012 +0000
+++ b/sys/arch/sparc/dev/sbus.c Mon Jan 30 04:25:14 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sbus.c,v 1.75 2011/07/01 18:50:41 dyoung Exp $ */
+/*     $NetBSD: sbus.c,v 1.76 2012/01/30 04:25:14 mrg Exp $ */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -74,7 +74,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sbus.c,v 1.75 2011/07/01 18:50:41 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sbus.c,v 1.76 2012/01/30 04:25:14 mrg Exp $");
 
 #include <sys/param.h>
 #include <sys/malloc.h>
@@ -444,7 +444,7 @@
        error = prom_getprop(node, "name", 1, &n, &sa->sa_name);
        if (error != 0)
                return (error);
-       sa->sa_name[n] = '\0';
+       KASSERT(sa->sa_name[n-1] == '\0');
 
        sa->sa_bustag = bustag;
        sa->sa_dmatag = dmatag;
diff -r f14e8d56e524 -r ade53284df3f sys/arch/sparc64/dev/ebus.c
--- a/sys/arch/sparc64/dev/ebus.c       Mon Jan 30 03:28:33 2012 +0000
+++ b/sys/arch/sparc64/dev/ebus.c       Mon Jan 30 04:25:14 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ebus.c,v 1.59 2011/07/20 12:06:00 macallan Exp $       */
+/*     $NetBSD: ebus.c,v 1.60 2012/01/30 04:25:15 mrg Exp $    */
 
 /*
  * Copyright (c) 1999, 2000, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ebus.c,v 1.59 2011/07/20 12:06:00 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ebus.c,v 1.60 2012/01/30 04:25:15 mrg Exp $");
 
 #include "opt_ddb.h"
 
@@ -226,7 +226,7 @@
        rv = prom_getprop(node, "name", 1, &n, &ea->ea_name);
        if (rv != 0)
                return (rv);
-       ea->ea_name[n] = '\0';
+       KASSERT(ea->ea_name[n-1] == '\0');
 
        ea->ea_node = node;
        ea->ea_bustag = sc->sc_childbustag;
diff -r f14e8d56e524 -r ade53284df3f sys/arch/sparc64/dev/sbus.c
--- a/sys/arch/sparc64/dev/sbus.c       Mon Jan 30 03:28:33 2012 +0000
+++ b/sys/arch/sparc64/dev/sbus.c       Mon Jan 30 04:25:14 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sbus.c,v 1.92 2011/09/04 12:17:14 nakayama Exp $ */
+/*     $NetBSD: sbus.c,v 1.93 2012/01/30 04:25:15 mrg Exp $ */
 
 /*
  * Copyright (c) 1999-2002 Eduardo Horvath
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sbus.c,v 1.92 2011/09/04 12:17:14 nakayama Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sbus.c,v 1.93 2012/01/30 04:25:15 mrg Exp $");
 
 #include "opt_ddb.h"
 
@@ -315,7 +315,7 @@
        error = prom_getprop(node, "name", 1, &n, &sa->sa_name);
        if (error != 0)
                return (error);
-       sa->sa_name[n] = '\0';
+       KASSERT(sa->sa_name[n-1] == '\0');
 
        sa->sa_bustag = bustag;
        sa->sa_dmatag = dmatag;



Home | Main Index | Thread Index | Old Index