Nmap Development mailing list archives
Re: Compile error on netbsd
From: Jay Fink <jay.fink () gmail com>
Date: Thu, 27 Aug 2009 18:53:54 -0400
The problem is only on netbsd, when I did a clean build on freebsd it works fine although you need to be root to get all of the information. Will keep working on the netbsd side only. On Wed, Aug 26, 2009 at 8:58 PM, Jay Fink<jay.fink () gmail com> wrote:
I tried the following with interesting results when using --iflist: --- tcpip.cc.orig 2009-08-26 20:42:00.000000000 -0400 +++ tcpip.cc 2009-08-26 20:42:16.000000000 -0400 @@ -2945,7 +2945,7 @@ ifr = ifc.ifc_req; for(ifr = ifc.ifc_req; - ifr && ifr->ifr_name[0] && (void *) ifr < ifc.ifc_buf + ifc.ifc_len; + ifr && ifr->ifr_name[0] && (void *) ifr < (char *) ifc.ifc_buf + ifc.ifc_len; ifr = (struct ifreq *) ((char *) ifr + len)) { struct sockaddr_in *sin; struct ifreq tmpifr; @@ -2956,7 +2956,8 @@ /* 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. */ #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)); #else len = sizeof(struct ifreq); #endif On debian-current; no change. On FreeBSD 8.0-CURRENT-200809 I get the following: [20:08:35 jrf@pyxis:~/nmap]$ ./nmap --iflist Starting Nmap 5.05BETA1 ( http://nmap.org ) at 2009-08-26 20:08 EDT INTERFACES: NONE FOUND(!) WARNING: Unable to find appropriate interface for system route to 192.168.1.1 WARNING: Unable to find appropriate interface for system route to 127.0.0.1 ROUTES: NONE FOUND(!) On NetBSD 5.99.11 nmap --iflist hangs indefinitely; if I revert the second part of the changes, NetBSD spits back the same error as FreeBSD. I'll work on these over the next few days to see if I can get it to build on those systems. Thanks, Jay On Wed, Aug 26, 2009 at 8:30 PM, Jay Fink<jay.fink () gmail com> wrote:This is patch doesn't address the error I saw; I am still looking into it. On Tue, Aug 25, 2009 at 8:36 AM, Jay Fink<jay.fink () gmail com> wrote: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 2Can 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:
- Compile error on netbsd Jay Fink (Aug 24)
- Re: Compile error on netbsd David Fifield (Aug 24)
- Re: Compile error on netbsd Jay Fink (Aug 25)
- Re: Compile error on netbsd Jay Fink (Aug 26)
- Re: Compile error on netbsd Jay Fink (Aug 26)
- Re: Compile error on netbsd Jay Fink (Aug 27)
- Re: Compile error on netbsd Jay Fink (Aug 28)
- Re: Compile error on netbsd David Fifield (Aug 28)
- Re: Compile error on netbsd Jay Fink (Aug 28)
- Re: Compile error on netbsd Jay Fink (Aug 31)
- Re: Compile error on netbsd David Fifield (Aug 31)
- Re: Compile error on netbsd Jay Fink (Aug 31)
- Re: Compile error on netbsd David Fifield (Aug 31)
- Re: Compile error on netbsd Jay Fink (Aug 31)
- Re: Compile error on netbsd Jay Fink (Aug 25)
- Re: Compile error on netbsd David Fifield (Aug 24)
- Re: Compile error on netbsd David Fifield (Aug 31)
- Re: Compile error on netbsd Jay Fink (Aug 31)