Nmap Development mailing list archives

getinterfaces on NetBSD


From: David Fifield <david () bamsoftware com>
Date: Thu, 25 Mar 2010 15:03:04 -0600

On Tue, Mar 23, 2010 at 06:22:26PM +0100, Fredrik Pettai wrote:
bash-4.0# nmap --iflist

Starting Nmap 5.21 ( http://nmap.org ) at 2010-03-23 18:03 CET
INTERFACES: NONE FOUND(!)
WARNING: Unable to find appropriate interface for system route to  
193.10.5.1
WARNING: Unable to find appropriate interface for system route to  
127.0.0.1
WARNING: Unable to find appropriate interface for system route to  
127.0.0.1
ROUTES: NONE FOUND(!)

I can reproduce this now on NetBSD. I found that this has been reported
before: http://seclists.org/nmap-dev/2009/q3/749. This revealed that
there is a NetBSD patch in the pkgsrc tree, at

http://cvsweb.se.netbsd.org/cgi-bin/bsdweb.cgi/pkgsrc/net/nmap/patches/patch-ad?rev=1.13;content-type=text%2Fplain

The important issue is probably not Nmap 5.00 versus 5.21, but patched
versus non-patched. Applying the patch fixes the problem for me. A newer
revision of the patch,

http://cvsweb.se.netbsd.org/cgi-bin/bsdweb.cgi/pkgsrc/net/nmap/patches/patch-ad?rev=1.14;content-type=text%2Fplain

looks wrong to me. The line
+    len = ifr->ifr_addr.sa_len > sizeof(ifr->ifr_name);
should instead be
+    if (ifr->ifr_addr.sa_len > sizeof(ifr->ifr_ifru))

Incidentally, Fredrik, I see the name "pettai" in the pkgsrc tree; are
you maintaining Nmap for NetBSD now?

I can agree with the logic used in the patch, and in fact it agrees with
the ifreq code in Unix Network Programming, 3rd Edition, section 17.6.
The sa_len member may make the block of memory reserved for an ifreq
longer, but it may not make it shorter than sizeof(struct ifreq). This
is reflected by the "max" in UNP in the code

#ifdef HAVE_SOCKADDR_SA_LEN
        len = max(sizeof(struct sockaddr), ifr->ifr_addr.sa_len);
#else

I would commit this patch right away, except that the current code seems
to have been working fine on FreeBSD. Depending on how SIOCGIFCONF is
implemented on FreeBSD, this patch may break it. So I would appreciate
someone first testing --iflist with the attached patch on FreeBSD.

David Fifield

Attachment: nmap-ifreq.diff
Description:

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

Current thread: