Module Name:    src
Committed By:   bouyer
Date:           Thu Mar 15 18:35:20 UTC 2012

Modified Files:
        src/sys/dev/ic: dpt.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/dev/ic/dpt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ic/dpt.c
diff -u src/sys/dev/ic/dpt.c:1.66 src/sys/dev/ic/dpt.c:1.67
--- src/sys/dev/ic/dpt.c:1.66	Sun Aug  7 13:39:24 2011
+++ src/sys/dev/ic/dpt.c	Thu Mar 15 18:35:20 2012
@@ -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 @@ dpt_init(struct dpt_softc *sc, const cha
 	 * 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';

Reply via email to