Module Name:    src
Committed By:   bouyer
Date:           Thu Mar 15 16:17:48 UTC 2012

Modified Files:
        src/sys/compat/linux/common: linux_socket.c
        src/sys/compat/linux32/common: linux32_socket.c

Log Message:
Do not read past end of array. Found by gcc -03


To generate a diff of this commit:
cvs rdiff -u -r1.112 -r1.113 src/sys/compat/linux/common/linux_socket.c
cvs rdiff -u -r1.15 -r1.16 src/sys/compat/linux32/common/linux32_socket.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/compat/linux/common/linux_socket.c
diff -u src/sys/compat/linux/common/linux_socket.c:1.112 src/sys/compat/linux/common/linux_socket.c:1.113
--- src/sys/compat/linux/common/linux_socket.c:1.112	Fri Jan 20 14:08:07 2012
+++ src/sys/compat/linux/common/linux_socket.c	Thu Mar 15 16:17:48 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_socket.c,v 1.112 2012/01/20 14:08:07 joerg Exp $	*/
+/*	$NetBSD: linux_socket.c,v 1.113 2012/03/15 16:17:48 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.112 2012/01/20 14:08:07 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.113 2012/03/15 16:17:48 bouyer Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -1203,7 +1203,7 @@ linux_getifhwaddr(struct lwp *l, registe
 
 	if (strncmp(lreq.ifr_name, "eth", 3) == 0) {
 		for (ifnum = 0, index = 3;
-		     lreq.ifr_name[index] != '\0' && index < LINUX_IFNAMSIZ;
+		     index < LINUX_IFNAMSIZ && lreq.ifr_name[index] != '\0';
 		     index++) {
 			ifnum *= 10;
 			ifnum += lreq.ifr_name[index] - '0';

Index: src/sys/compat/linux32/common/linux32_socket.c
diff -u src/sys/compat/linux32/common/linux32_socket.c:1.15 src/sys/compat/linux32/common/linux32_socket.c:1.16
--- src/sys/compat/linux32/common/linux32_socket.c:1.15	Sat Dec 12 10:30:09 2009
+++ src/sys/compat/linux32/common/linux32_socket.c	Thu Mar 15 16:17:48 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux32_socket.c,v 1.15 2009/12/12 10:30:09 njoly Exp $ */
+/*	$NetBSD: linux32_socket.c,v 1.16 2012/03/15 16:17:48 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: linux32_socket.c,v 1.15 2009/12/12 10:30:09 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux32_socket.c,v 1.16 2012/03/15 16:17:48 bouyer Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -533,7 +533,7 @@ linux32_getifhwaddr(struct lwp *l, regis
 
 	if (strncmp(lreq.ifr_name, "eth", 3) == 0) {
 		for (ifnum = 0, index = 3;
-		     lreq.ifr_name[index] != '\0' && index < LINUX32_IFNAMSIZ;
+		     index < LINUX32_IFNAMSIZ && lreq.ifr_name[index] != '\0';
 		     index++) {
 			ifnum *= 10;
 			ifnum += lreq.ifr_name[index] - '0';

Reply via email to