Source-Changes-HG archive

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

[src/trunk]: src/sys/compat Do not read past end of array. Found by gcc -03



details:   https://anonhg.NetBSD.org/src/rev/e841dca86fc2
branches:  trunk
changeset: 778082:e841dca86fc2
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Thu Mar 15 16:17:48 2012 +0000

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

diffstat:

 sys/compat/linux/common/linux_socket.c     |  6 +++---
 sys/compat/linux32/common/linux32_socket.c |  6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diffs (54 lines):

diff -r cafb3438ec0a -r e841dca86fc2 sys/compat/linux/common/linux_socket.c
--- a/sys/compat/linux/common/linux_socket.c    Thu Mar 15 15:49:59 2012 +0000
+++ b/sys/compat/linux/common/linux_socket.c    Thu Mar 15 16:17:48 2012 +0000
@@ -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 @@
 
        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';
diff -r cafb3438ec0a -r e841dca86fc2 sys/compat/linux32/common/linux32_socket.c
--- a/sys/compat/linux32/common/linux32_socket.c        Thu Mar 15 15:49:59 2012 +0000
+++ b/sys/compat/linux32/common/linux32_socket.c        Thu Mar 15 16:17:48 2012 +0000
@@ -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 @@
 
        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';



Home | Main Index | Thread Index | Old Index