Nmap Development mailing list archives

Re: Compile error on netbsd


From: Jay Fink <jay.fink () gmail com>
Date: Tue, 25 Aug 2009 08:36:59 -0400

Bingo - it is in the netbsd pkgsrc tree as one of the patches as well;
here is the relevant info from netbsd's pkgsrc patch, I can try to
work into the mainline if you'd like. There is another one as well
which looks even easier.

--- tcpip.cc.orig       2008-09-04 14:41:59.000000000 +0000
+++ tcpip.cc
@@ -2890,12 +2890,10 @@ int sd;
     ifr = (struct ifreq *) buf;
     if (ifc.ifc_len == 0)
       fatal("%s: SIOCGIFCONF claims you have no network
interfaces!\n", __func__);
-#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

     /* Debugging code
@@ -2914,10 +2912,13 @@ int sd;
       printf("ifr = %X\n",(unsigned)(*(char **)&ifr));
       */

-      /* 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 */
+      /* On platforms where struct sockaddr has an sa_len member, if
+        ifr_ddr.sa_len is larger then sizeof ifr_ifru, then the actual
+        data extends beyond the end of ifr_ifru. */
+      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 */




On Mon, Aug 24, 2009 at 11:55 PM, David Fifield<david () bamsoftware com> wrote:
On Mon, Aug 24, 2009 at 08:11:23PM -0400, Jay Fink wrote:
Got an interesting compile error on a NetBSD5 snapshot:
tcpip.cc: In function 'interface_info* getinterfaces_siocgifconf(int*)':
tcpip.cc:2948: error: pointer of type 'void *' used in arithmetic
gmake[1]: *** [tcpip.o] Error 1
gmake[1]: Leaving directory `/home/jrf/nmap'
gmake: *** [all] Error 2

Can you find out the definition of struct ifconf? Particularly the type
of the ifc_buf member. Perhaps it's a void pointer instead of a char
pointer like on Linux. It should be in <net/if.h>.

David Fifield


_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://SecLists.Org


Current thread: