Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ic Do not read past array end; found by gcc -O3



details:   https://anonhg.NetBSD.org/src/rev/a0d3f4ddf7ff
branches:  trunk
changeset: 778088:a0d3f4ddf7ff
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Thu Mar 15 18:35:20 2012 +0000

description:
Do not read past array end; found by gcc -O3

diffstat:

 sys/dev/ic/dpt.c |  10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diffs (37 lines):

diff -r 923a026afa60 -r a0d3f4ddf7ff sys/dev/ic/dpt.c
--- a/sys/dev/ic/dpt.c  Thu Mar 15 18:34:40 2012 +0000
+++ b/sys/dev/ic/dpt.c  Thu Mar 15 18:35:20 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dpt.c,v 1.66 2011/08/07 13:39:24 rmind Exp $   */
+/*     $NetBSD: dpt.c,v 1.67 2012/03/15 18:35:20 bouyer Exp $  */
 
 /*-
  * Copyright (c) 1997, 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dpt.c,v 1.66 2011/08/07 13:39:24 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dpt.c,v 1.67 2012/03/15 18:35:20 bouyer Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -417,15 +417,15 @@
         * dpt0: interrupting at irq 10
         * dpt0: 64 queued commands, 1 channel(s), adapter on ID(s) 7
         */
-       for (i = 0; ei->ei_vendor[i] != ' ' && i < __arraycount(ei->ei_vendor);
+       for (i = 0; i < __arraycount(ei->ei_vendor) && ei->ei_vendor[i] != ' ';
            i++)
                vendor[i] = ei->ei_vendor[i];
        vendor[i] = '\0';
 
-       for (i = 0; ei->ei_model[i] != ' ' && i < __arraycount(ei->ei_model);
+       for (i = 0; i < __arraycount(ei->ei_model) && ei->ei_model[i] != ' ';
            i++)
                model[i] = ei->ei_model[i];
-       for (j = 0; ei->ei_suffix[j] != ' ' && j < __arraycount(ei->ei_suffix);
+       for (j = 0; j < __arraycount(ei->ei_suffix) && ei->ei_suffix[j] != ' ';
            i++, j++)
                model[i] = ei->ei_suffix[j];
        model[i] = '\0';



Home | Main Index | Thread Index | Old Index