Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/ia64/stand/ia64/ski Two uninitialized vars, found b...



details:   https://anonhg.NetBSD.org/src/rev/a90a27874cf4
branches:  trunk
changeset: 347126:a90a27874cf4
user:      maxv <maxv%NetBSD.org@localhost>
date:      Mon Aug 15 09:06:39 2016 +0000

description:
Two uninitialized vars, found by brainy. The former is similar to the one
I fixed in ia64/stand/efi/libefi/devicename.c. I don't know how to fix the
latter, so just add a comment. I will probably file a PR for this one.

diffstat:

 sys/arch/ia64/stand/ia64/ski/devicename.c |  13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diffs (48 lines):

diff -r 020f73abd13f -r a90a27874cf4 sys/arch/ia64/stand/ia64/ski/devicename.c
--- a/sys/arch/ia64/stand/ia64/ski/devicename.c Mon Aug 15 09:00:52 2016 +0000
+++ b/sys/arch/ia64/stand/ia64/ski/devicename.c Mon Aug 15 09:06:39 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: devicename.c,v 1.7 2014/04/08 21:51:06 martin Exp $    */
+/*     $NetBSD: devicename.c,v 1.8 2016/08/15 09:06:39 maxv Exp $      */
 
 /*-
  * Copyright (c) 1998 Michael Smith <msmith%freebsd.org@localhost>
@@ -91,7 +91,7 @@
        struct devsw    *dv;
        int dv_type;
        int             i, unit, slice, partition, err;
-       char            *cp;
+       char            *cp = NULL;
        const char      *np;
 
        /* minimum length check */
@@ -146,6 +146,10 @@
                                cp++;
                        }
                }
+               if (cp == NULL) {
+                       err = EINVAL;
+                       goto fail;
+               }
                if (*cp && (*cp != ':')) {
                        err = EINVAL;
                        goto fail;
@@ -169,6 +173,10 @@
                                goto fail;
                        }
                }
+               if (cp == NULL) {
+                       err = EINVAL;
+                       goto fail;
+               }
                if (*cp && (*cp != ':')) {
                        err = EINVAL;
                        goto fail;
@@ -228,6 +236,7 @@
                break;
 
        case DEVT_NET:
+               /* XXX XXX XXX: Yay, 'len' is not initialized here */
                snprintf(buf, buflen - len, "%s%d:", dev->d_dev->dv_name, dev->d_kind.netif.unit);
                break;
        }



Home | Main Index | Thread Index | Old Index