Nmap Development mailing list archives

Re: nmap 6.47 compile failure on AIX 7100-03


From: Daniel Miller <bonsaiviking () gmail com>
Date: Tue, 9 Sep 2014 00:06:41 -0500

Kevin,

I had already committed almost that exact fix in r33660. Now r33661 solves
an interaction I had with the older version of GCC that is available on the
AIX system I'm testing on. At this point, Nmap compiles but fails to scan:

./nmap --iflist

Starting Nmap 6.47SVN ( http://nmap.org ) at 2014-09-09 00:00 CDT
INTERFACES: NONE FOUND(!)
ROUTES: NONE FOUND(!)


I will continue to work on this as time permits.

Dan


On Mon, Sep 8, 2014 at 5:42 PM, Kevin Brott <kevin.brott () gmail com> wrote:

Actually I have a fix for that already:

# this patch fixes this issue ... AIX has a slightly different structure
here ...
---CUT---
*** nmap-6.46.orig/TargetGroup.cc       2013-09-11 12:06:20.000000000 -0700
--- nmap-6.46/TargetGroup.cc    2014-08-13 15:25:00.529370342 -0700
***************
*** 549,556 ****
--- 549,561 ----
  }

  void NetBlockIPv6Netmask::apply_netmask(int bits) {
+ #ifdef _AIX
+   const struct in6_addr zeros = { { { 0x00000000, 0x00000000,
0x00000000, 0x00000000 } } };
+   const struct in6_addr ones = { { { 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff } } };
+ #else
    const struct in6_addr zeros = { { { 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} } };
    const struct in6_addr ones = { { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff} } };
+ #endif
    struct in6_addr mask;

    if (bits > 128)
---CUT---

On Mon, Sep 8, 2014 at 1:52 PM, Daniel Miller <bonsaiviking () gmail com>
wrote:

On Tue, Sep 2, 2014 at 6:12 PM, Kevin Brott <kevin.brott () gmail com>
wrote:

Looks to possibly(?) be an issue with NEXTSA/ROUNDUP on this platform.
Noted that 6.25 builds and runs on this platform without issue, but
nothing
more recent than that (including an SVN pull from today).

oslevel 7100-03-03-1415 :: gcc (GCC) 4.4.7 :: GNU Make 3.82

$ ./configure --prefix=/opt/nmap --mandir=/opt/nmap/man \
  --with-liblinear=included --with-liblua=included \
  --with-libdnet=included --with-libpcre=included
  --with-libpcap=included && echo OK || echo FAIL
...
Configuration complete.  Type make (or gmake on some *BSD machines) to
compile.
OK

$ gmake
...
gcc -DHAVE_CONFIG_H -I. -I../include -I../include -g -O2 -Wall -c
route-bsd.c -o route-bsd.o
route-bsd.c: In function 'route_msg':
route-bsd.c:108: error: invalid type argument of '->' (have 'int')
route-bsd.c:108: error: invalid type argument of '->' (have 'int')
route-bsd.c:116: error: invalid type argument of '->' (have 'int')
route-bsd.c:116: error: invalid type argument of '->' (have 'int')
route-bsd.c:123: error: invalid type argument of '->' (have 'int')
route-bsd.c:123: error: invalid type argument of '->' (have 'int')
route-bsd.c:157: error: invalid type argument of '->' (have 'int')
route-bsd.c:157: error: invalid type argument of '->' (have 'int')
route-bsd.c: In function 'route_loop':
route-bsd.c:294: warning: implicit declaration of function 'getkerninfo'
route-bsd.c:354: error: invalid type argument of '->' (have 'int')
route-bsd.c:354: error: invalid type argument of '->' (have 'int')
route-bsd.c:364: error: invalid type argument of '->' (have 'int')
route-bsd.c:364: error: invalid type argument of '->' (have 'int')
gmake[2]: *** [route-bsd.lo] Error 1
gmake[2]: Leaving directory
`/lppdir/build/nmap-6.47/libdnet-stripped/src'
gmake[1]: *** [all-recursive] Error 1
gmake[1]: Leaving directory `/lppdir/build/nmap-6.47/libdnet-stripped'
gmake: *** [dnet_build] Error 2

Searching the 'net seems to indicate an undefined function call, but
determining exactly which one and why is beyond my current skillset.
 Pointers?  Missed gcc or AIX networking FAQ? A polite(?!) sod-off?


Kevin,

Thanks for bringing this up. Turns out AIX defines RT_ROUNDUP in
net/route.h as:

#define RT_ROUNDUP(sa)  ((sa)->sa_len > 0 ? \
                                (1 + (((sa)->sa_len-1) |
(sizeof(int)-1))) : \
                                 sizeof(int))

And we use RT_ROUNDUP as a replacement for ROUNDUP due to better 64-bit
handling on NetBSD (line 50),
But we are expecting a definition for ROUNDUP that fits the one on line
55:

#define ROUNDUP(a) \
  ((a) > 0 ? (1 + (((a) - 1) | (RT_MSGHDR_ALIGNMENT - 1))) :
RT_MSGHDR_ALIGNMENT)

On line 60, NEXTSA is defined:

#define NEXTSA(s) \
  ((struct sockaddr *)((u_char *)(s) + ROUNDUP((s)->sa_len))

So when we run this through the C preprocessor (cpp -I../include
route-bsd.c), we get this expansion:

sa = ((struct sockaddr *)((u_char *)(sa) + (((sa)->sa_len)->sa_len > 0 ?
(1 + ((((sa)->sa_len)->sa_len-1) | (sizeof(int)-1))) : sizeof(int))));

The "->sa_len" is being applied twice! Naturally, this results in a type
error. As a solution, I added a check for __NetBSD__ to ensure we only use
RT_ROUNDUP on that platform. Should be fixed in r33657.

Unfortunately, we still have problems:

g++ -c -I./liblinear -I./liblua -I./libdnet-stripped/include -I./libpcre
-I./libpcap -I./nbase -I./nsock/include -DHAVE_CONFIG_H
-DNMAP_NAME=\"Nmap\" -DNMAP_URL=\"http://nmap.org\";
-DNMAP_PLATFORM=\"powerpc-ibm-aix7.1.0.0\"
-DNMAPDATADIR=\"/usr/local/share/nmap\" -D_FORTIFY_SOURCE=2 -g -O2 -Wall
-fno-strict-aliasing   TargetGroup.cc -o TargetGroup.o
TargetGroup.cc: In member function 'virtual void
NetBlockIPv6Netmask::apply_netmask(int)':
TargetGroup.cc:551: error: too many initializers for 'u_int32_t [4]'
TargetGroup.cc:552: error: too many initializers for 'u_int32_t [4]'
make[1]: *** [TargetGroup.o] Error 1

Stay tuned for more fixes!

Dan




--
# include <stddisclaimer.h>
/* Kevin  Brott <Kevin.Brott () gmail com> */


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


Current thread: