Source-Changes-HG archive

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

[src/netbsd-3-0]: src/sys/net Pull up following revision(s) (requested by chr...



details:   https://anonhg.NetBSD.org/src/rev/bd8fd29ca7d8
branches:  netbsd-3-0
changeset: 579330:bd8fd29ca7d8
user:      ghen <ghen%NetBSD.org@localhost>
date:      Fri Oct 27 18:55:11 2006 +0000

description:
Pull up following revision(s) (requested by christos in ticket #1572):
        sys/net/if.c: revision 1.175
Use strncpy to copy out interface names so that the trailing part of the
buffer is zeroed, and check for overflow.

diffstat:

 sys/net/if.c |  12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diffs (41 lines):

diff -r 8d48bb2ddf94 -r bd8fd29ca7d8 sys/net/if.c
--- a/sys/net/if.c      Thu Oct 26 10:53:55 2006 +0000
+++ b/sys/net/if.c      Fri Oct 27 18:55:11 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.c,v 1.154.2.1.2.1 2006/10/26 10:52:57 ghen Exp $    */
+/*     $NetBSD: if.c,v 1.154.2.1.2.2 2006/10/27 18:55:11 ghen Exp $    */
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.154.2.1.2.1 2006/10/26 10:52:57 ghen Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.154.2.1.2.2 2006/10/27 18:55:11 ghen Exp $");
 
 #include "opt_inet.h"
 
@@ -933,7 +933,9 @@
 
        for (ifc = LIST_FIRST(&if_cloners); ifc != NULL && count != 0;
             ifc = LIST_NEXT(ifc, ifc_list), count--, dst += IFNAMSIZ) {
-               (void)strlcpy(outbuf, ifc->ifc_name, sizeof(outbuf));
+               (void)strncpy(outbuf, ifc->ifc_name, sizeof(outbuf));
+               if (outbuf[sizeof(outbuf) - 1] != '\0')
+                       return ENAMETOOLONG;
                error = copyout(outbuf, dst, sizeof(outbuf));
                if (error)
                        break;
@@ -1692,8 +1694,10 @@
                sign = 1;
        }
        IFNET_FOREACH(ifp) {
-               (void)strlcpy(ifr.ifr_name, ifp->if_xname,
+               (void)strncpy(ifr.ifr_name, ifp->if_xname,
                    sizeof(ifr.ifr_name));
+               if (ifr.ifr_name[sizeof(ifr.ifr_name) - 1] != '\0')
+                       return ENAMETOOLONG;
                if ((ifa = TAILQ_FIRST(&ifp->if_addrlist)) == 0) {
                        memset(&ifr.ifr_addr, 0, sizeof(ifr.ifr_addr));
                        if (ifrp != NULL && space >= sz) {



Home | Main Index | Thread Index | Old Index