Source-Changes-HG archive

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

[src/netbsd-1-5]: src/sys/net Pull up 1.69-1.70 - kernel portion of fix for P...



details:   https://anonhg.NetBSD.org/src/rev/e050e4d35fc8
branches:  netbsd-1-5
changeset: 489645:e050e4d35fc8
user:      mellon <mellon%NetBSD.org@localhost>
date:      Mon Oct 02 20:54:46 2000 +0000

description:
Pull up 1.69-1.70 - kernel portion of fix for PR#10968 (jhawk approved)

diffstat:

 sys/net/if.c |  57 ++++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 34 insertions(+), 23 deletions(-)

diffs (89 lines):

diff -r 9f92a44cb0fe -r e050e4d35fc8 sys/net/if.c
--- a/sys/net/if.c      Mon Oct 02 20:11:25 2000 +0000
+++ b/sys/net/if.c      Mon Oct 02 20:54:46 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.c,v 1.62.4.2 2000/07/21 18:56:02 onoe Exp $ */
+/*     $NetBSD: if.c,v 1.62.4.3 2000/10/02 20:54:46 mellon Exp $       */
 
 /*-
  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -1038,18 +1038,19 @@
        int space = ifc->ifc_len, error = 0;
 
        ifrp = ifc->ifc_req;
-       for (ifp = ifnet.tqh_first;
-           space >= sizeof (ifr) && ifp != 0; ifp = ifp->if_list.tqe_next) {
+       for (ifp = ifnet.tqh_first; ifp != 0; ifp = ifp->if_list.tqe_next) {
                bcopy(ifp->if_xname, ifr.ifr_name, IFNAMSIZ);
                if ((ifa = ifp->if_addrlist.tqh_first) == 0) {
                        bzero((caddr_t)&ifr.ifr_addr, sizeof(ifr.ifr_addr));
-                       error = copyout((caddr_t)&ifr, (caddr_t)ifrp,
-                           sizeof(ifr));
-                       if (error)
-                               break;
+                       if (space >= (int)sizeof (ifr)) {
+                               error = copyout((caddr_t)&ifr, (caddr_t)ifrp,
+                                               sizeof(ifr));
+                               if (error)
+                                       break;
+                       }
                        space -= sizeof (ifr), ifrp++;
                } else 
-                   for (; space >= sizeof (ifr) && ifa != 0; ifa = ifa->ifa_list.tqe_next) {
+                   for (; ifa != 0; ifa = ifa->ifa_list.tqe_next) {
                        struct sockaddr *sa = ifa->ifa_addr;
 #if defined(COMPAT_43) || defined(COMPAT_LINUX) || defined(COMPAT_SVR4)
                        if (cmd == OSIOCGIFCONF) {
@@ -1057,27 +1058,37 @@
                                         (struct osockaddr *)&ifr.ifr_addr;
                                ifr.ifr_addr = *sa;
                                osa->sa_family = sa->sa_family;
-                               error = copyout((caddr_t)&ifr, (caddr_t)ifrp,
-                                               sizeof (ifr));
-                               ifrp++;
+                               if (space >= (int)sizeof (ifr)) {
+                                       error = copyout((caddr_t)&ifr,
+                                                       (caddr_t)ifrp,
+                                                       sizeof (ifr));
+                                       ifrp++;
+                               }
                        } else
 #endif
                        if (sa->sa_len <= sizeof(*sa)) {
                                ifr.ifr_addr = *sa;
-                               error = copyout((caddr_t)&ifr, (caddr_t)ifrp,
-                                               sizeof (ifr));
-                               ifrp++;
+                               if (space >= (int)sizeof (ifr)) {
+                                       error = copyout((caddr_t)&ifr,
+                                                       (caddr_t)ifrp,
+                                                       sizeof (ifr));
+                                       ifrp++;
+                               }
                        } else {
                                space -= sa->sa_len - sizeof(*sa);
-                               if (space < sizeof (ifr))
-                                       break;
-                               error = copyout((caddr_t)&ifr, (caddr_t)ifrp,
-                                               sizeof (ifr.ifr_name));
-                               if (error == 0)
-                                   error = copyout((caddr_t)sa,
-                                     (caddr_t)&ifrp->ifr_addr, sa->sa_len);
-                               ifrp = (struct ifreq *)
-                                       (sa->sa_len + (caddr_t)&ifrp->ifr_addr);
+                               if (space >= (int)sizeof (ifr)) {
+                                       error = copyout((caddr_t)&ifr,
+                                                       (caddr_t)ifrp,
+                                                       sizeof (ifr.ifr_name));
+                                       if (error == 0) {
+                                               error = copyout((caddr_t)sa,
+                                                 (caddr_t)&ifrp->ifr_addr,
+                                                 sa->sa_len);
+                                       }
+                                       ifrp = (struct ifreq *)
+                                               (sa->sa_len +
+                                                (caddr_t)&ifrp->ifr_addr);
+                               }
                        }
                        if (error)
                                break;



Home | Main Index | Thread Index | Old Index