Nmap Development mailing list archives

Re: Your (?) Nmap patch


From: Gioacchino Mazzurco <gmazzurco89 () gmail com>
Date: Mon, 17 Aug 2015 15:33:12 +0200

Ok it seems have a very simple fix just by moving

struct sockaddr_in * addrv4p = (struct sockaddr_in *) addr;

as first line of the function, if there is no negative feedback to this I'll 
commit it in the following days ;)

Cheers!

On Monday, August 17, 2015 12:20:23 PM Gisle Vanem wrote:
Gioacchino Mazzurco <gmazzurco89 () gmail com> wrote:
This doesn't work with a non-C99 compiler:
Does nmap supports older compilers?

Define "older". Microsoft Visual-C 2013 isn't that old. It has worked
fine for the .c code since it was released (except the nsock/tests/*.c
code with *require* gcc).

+int sockaddr_storage_inet_pton(const char * ip_str, struct
sockaddr_storage * addr) +{
+#if HAVE_IPV6
+  struct sockaddr_in6 * addrv6p = (struct sockaddr_in6 *) addr;
+  if ( 1 == inet_pton(AF_INET6, ip_str, &(addrv6p->sin6_addr)) )
+  {
+    addr->ss_family = AF_INET6;
+    return 1;
+  }
+#endif // HAVE_IPV6
+
+  struct sockaddr_in * addrv4p = (struct sockaddr_in *) addr;
+  if ( 1 == inet_pton(AF_INET, ip_str, &(addrv4p->sin_addr)) )


I.e. potentially declarations after code.

The problem is tha ti don't see the declarations after code, some
suggestion on how to fix that ?

With 'HAVE_IPV6 == 1', you'll get:
  struct sockaddr_in6 * addrv6p = ...
  if (xxx)
      ...
   struct sockaddr_in * addrv4p = ...

which needs a C99 compiler AFAICS. Since compiling nbase/*.c as C++
is impossible, you could change sockaddr_storage_inet_pton() and into
legal C-89. Try with 'gcc -ansi' or something.

P.S. maybe better to talk this on the devel list it is ok for you if i
forward it ?

CC'ed.

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


Current thread: