Nmap Development mailing list archives

Re: <netdb.h> in nsock/src/


From: Gisle Vanem <gvanem () broadpark no>
Date: Wed, 01 May 2013 14:24:25 +0200

"Henri Doreau" <henri.doreau () gmail com> wrote:

2013/4/30 Gisle Vanem <gvanem () broadpark no>:
Some nsock files now includes <netdb.h>.
These should have a guard; "#if HAVE_NETDB_H".
We Windows (MSVC) users doesn't have this header.

So AFAICS these files should be fixed:
nsock\src\nsock_proxy.c
nsock\src\proxy_http.c
nsock\src\proxy_socks4.c

BTW. what about the use of strtok_r()? Missing on MSVC/MingW.

--gv
Hi,

thanks for the report. Could you give a try at the patch attached?

It looks good. But there are more problems in the nsock/src/*proxy*.c
files regarding support for my "old" MSVC. I use ver. 16.00 from VC-Express 2010 which should still be good enough for nmap-development. In proxy_socks4.c + proxy_http.c you use GCC features like:

/* ---- PROXY DEFINITION ---- */
static const struct proxy_op ProxyOpsHttp = {
 .node_new    = proxy_http_node_new,
 .node_delete = proxy_http_node_delete,
 .handler     = proxy_http_handler,
};

This is no good for MSVC. I'll address the other MSVC problems later.

Concerning strtok_r, would it be ok to simply #define strtok_r
strtok_s?

Why not add a macro for this to nbase.h? As we do for strcasecmp() etc?
But using 'strtok_s' would exclude MingW users. This is a pity IMHO.
I suggest adding the attached patch for 'strtok_r' to nbase_str.c. (ripped
from libcurl). So you should add a configure test for 'HAVE_STRTOK_R'.
I have little knowledge of autotools.

Patch to nbase.h:

--- SVN-Latest\nbase\nbase.h      Thu Apr 25 10:06:27 2013
+++ nbase\nbase.h Wed May 01 13:53:39 2013
@@ -412,6 +412,10 @@

#ifndef HAVE_STRNCASECMP
int strncasecmp(const char *s1, const char *s2, size_t n);
+#endif
+
+#ifndef HAVE_STRTOK_R
+char *strtok_r(char *ptr, const char *sep, char **end);
#endif

#ifndef HAVE_GETTIMEOFDAY

-----------

Patch to nbase_str.c attached (you'll probably have to patch by hand).

--gv

Attachment: nbase_str.diff
Description:

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

Current thread: