Source-Changes-HG archive

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

[src/trunk]: src/dist/libpcap Fix pcap_lookupnet(): reset ifr before SIOCGIFN...



details:   https://anonhg.NetBSD.org/src/rev/1ea070c52db3
branches:  trunk
changeset: 747727:1ea070c52db3
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Tue Sep 29 19:00:45 2009 +0000

description:
Fix pcap_lookupnet(): reset ifr before SIOCGIFNETMASK. Without it we get
back a bogus netmask.

diffstat:

 dist/libpcap/inet.c |  8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diffs (25 lines):

diff -r c045f232f016 -r 1ea070c52db3 dist/libpcap/inet.c
--- a/dist/libpcap/inet.c       Tue Sep 29 15:58:54 2009 +0000
+++ b/dist/libpcap/inet.c       Tue Sep 29 19:00:45 2009 +0000
@@ -34,7 +34,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /cvsroot/src/dist/libpcap/Attic/inet.c,v 1.2 2006/02/27 15:53:24 drochner Exp $ (LBL)";
+    "@(#) $Header: /cvsroot/src/dist/libpcap/Attic/inet.c,v 1.3 2009/09/29 19:00:45 bouyer Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -573,6 +573,12 @@
        }
        sin4 = (struct sockaddr_in *)&ifr.ifr_addr;
        *netp = sin4->sin_addr.s_addr;
+       memset(&ifr, 0, sizeof(ifr));
+#ifdef linux
+       /* XXX Work around Linux kernel bug */
+       ifr.ifr_addr.sa_family = AF_INET;
+#endif
+       (void)strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
        if (ioctl(fd, SIOCGIFNETMASK, (char *)&ifr) < 0) {
                (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
                    "SIOCGIFNETMASK: %s: %s", device, pcap_strerror(errno));



Home | Main Index | Thread Index | Old Index