pkgsrc-Users archive

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

Re: nmap not working



On Wed, 09 Apr 2008, Alan Barrett wrote:
> On Tue, 08 Apr 2008, Steven M. Bellovin wrote:
> > Nmap isn't working for me on -current.  I'm seeing messages like
> > I cannot figure out what source address to use for device bge0, does it
> > even exist?
> I looked at that code in nmap several months ago, and it was so horribly
> written that I gave up and used a wrapper script to pass appropriate "-e
> interface -S address" args to nmap.

Han on, I went back to it later, and produced this patch.  I can't remember
whether the patch was sufficient (I still use the wrapper script).

--apb (Alan Barrett)

--- tcpip.cc.orig       2006-12-08 05:01:19.000000000 +0200
+++ tcpip.cc
@@ -2606,12 +2606,10 @@ int sd;
     ifr = (struct ifreq *) buf;
     if (ifc.ifc_len == 0) 
       fatal("getinterfaces: SIOCGIFCONF claims you have no network 
interfaces!\n");
-#if HAVE_SOCKADDR_SA_LEN
-    /*    len = MAX(sizeof(struct sockaddr), ifr->ifr_addr.sa_len);*/
-    len = ifr->ifr_addr.sa_len + sizeof(ifr->ifr_name);
-#else
     len = sizeof(struct ifreq);
-    /* len = sizeof(SA); */
+#if HAVE_SOCKADDR_SA_LEN
+    if (ifr->ifr_addr.sa_len > sizeof(ifr->ifr_ifru))
+      len += (ifr->ifr_addr.sa_len - sizeof(ifr->ifr_ifru));
 #endif
 
 #if TCPIP_DEBUGGING
@@ -2631,8 +2629,10 @@ int sd;
 
       /* On some platforms (such as FreeBSD), the length of each ifr changes
         based on the sockaddr type used, so we get the next length now */
+      len = sizeof(struct ifreq);
 #if HAVE_SOCKADDR_SA_LEN
-      len = ifr->ifr_addr.sa_len + sizeof(ifr->ifr_name);
+      if (ifr->ifr_addr.sa_len > sizeof(ifr->ifr_ifru))
+        len += (ifr->ifr_addr.sa_len - sizeof(ifr->ifr_ifru));
 #endif 
 
       /* skip any device with no name */


Home | Main Index | Thread Index | Old Index