libnet 1.1.2 rc5 patch

"Gisle Vanem" <[email protected]>
Newsgroups gmane.comp.security.libnet
Message-ID <[email protected]>
The following patch is needed when one have multiple adapters.
E.g. I have these physical/pseudo adapters on Win-XP.

> tcpdump -Dv
1.\Device\NPF_{7F56352E-EF2F-49F4-844C-BA1FA0105667} (MS Tunnel Interface Driver) No address!
2.\Device\NPF_{93380695-0E31-456C-9EB0-8802E111C09D} (Realtek 8139-series PCI NIC) addr 10.0.0.6

(dev 1 is my IPv6/Teredo pseudo iface).

The problem shows up in the latest WinPcap 3.1 which reverses the order of
adapters compared to the 3.0 version. But any software using libpcap should
IMHO don't care about the order.

I've also made iptos() static (due to a name-clash with tcptraceroute).

--- orig\src\libnet_if_addr.c        Thu Jan 29 22:17:16 2004
+++ src\libnet_if_addr.c  Wed Feb 18 11:01:48 2004
@@ -265,10 +265,10 @@
     *ipaddrp = ifaddrlist;
     return (nipaddr);
 }
-#else
+#else  /* _WIN32 */
 /* From tcptraceroute, convert a numeric IP address to a string */
 #define IPTOSBUFFERS    12
-int8_t *iptos(u_int32_t in)
+static int8_t *iptos(u_int32_t in)
 {
     static int8_t output[IPTOSBUFFERS][ 3 * 4 + 3 + 1];
     static int16_t which;
@@ -302,9 +302,9 @@
     }

     /* Scan the list printing every entry */
-    for (d = alldevs; d && d->addresses; d = d->next)
+    for (d = alldevs; d; d = d->next)
     {
-        if (d->addresses->addr->sa_family != AF_INET)
+        if (!d->addresses || d->addresses->addr->sa_family != AF_INET)
         {
             continue;
         }

--------

Gisle V.

# rm /bin/laden 
/bin/laden: Not found
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.