Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/ofppc/ofppc Avoid NULL pointer dereference.



details:   https://anonhg.NetBSD.org/src/rev/400c9aae6a71
branches:  trunk
changeset: 513612:400c9aae6a71
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sun Aug 05 11:14:21 2001 +0000

description:
Avoid NULL pointer dereference.

diffstat:

 sys/arch/ofppc/ofppc/autoconf.c |  16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diffs (32 lines):

diff -r 58be0bea0cec -r 400c9aae6a71 sys/arch/ofppc/ofppc/autoconf.c
--- a/sys/arch/ofppc/ofppc/autoconf.c   Sun Aug 05 11:11:33 2001 +0000
+++ b/sys/arch/ofppc/ofppc/autoconf.c   Sun Aug 05 11:14:21 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autoconf.c,v 1.9 2000/06/01 15:38:26 matt Exp $        */
+/*     $NetBSD: autoconf.c,v 1.10 2001/08/05 11:14:21 tsutsui Exp $    */
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -84,14 +84,16 @@
        /*
         * Try to find the device where we were booted from.
         */
-       for (cp = bootpath + strlen(bootpath); --cp >= bootpath;) {
-               if (*cp == '/') {
-                       *cp = '\0';
-                       if (!dk_match(bootpath)) {
+       if (bootpath != NULL) {
+               for (cp = bootpath + strlen(bootpath); --cp >= bootpath;) {
+                       if (*cp == '/') {
+                               *cp = '\0';
+                               if (!dk_match(bootpath)) {
+                                       *cp = '/';
+                                       break;
+                               }
                                *cp = '/';
-                               break;
                        }
-                       *cp = '/';
                }
        }
        dk_cleanup();



Home | Main Index | Thread Index | Old Index