Nmap Development mailing list archives

Re: nmap-4.02CSW failed build on Windows XP built in VS 2005 Express


From: kx <kxmail () gmail com>
Date: Sat, 22 Apr 2006 00:15:46 -0400

_CRT_SECURE_NO_DEPRECATE fixes:

Patch worked for nbase_winconfig.h, dnet_winconfig.h, pcre_wincofig.h,

Leaves nmap project with 226 warnings.

Adding the define to nmap_winconfig.h, reduces this to 213
Adding #include "nmap_winconfig.h" in winclude.h reduces this to 96

Remaining offending files are:

tcpip.cc
Target.cc
scan_engine.cc
NmapOutputTable.cc
nmap_dns.cc

added

#ifdef WIN32
#include "nmap_winconfig.h"
#endif

to all of these.

Hope this was appropriate. This patch also has the pow() fix in it as well.

Cheers,
  kx

diff -urNb nmap-4.02CSW/NmapOutputTable.cc nmap-4.02CSW_patch/NmapOutputTable.cc
--- nmap-4.02CSW/NmapOutputTable.cc     2005-10-01 19:50:38.000000000 -0400
+++ nmap-4.02CSW_patch/NmapOutputTable.cc       2006-04-22 00:00:27.921875000 -0400
@@ -99,6 +99,10 @@

 /* $Id: NmapOutputTable.cc 2891 2005-10-01 23:50:27Z fyodor $ */

+#ifdef WIN32
+#include "nmap_winconfig.h"
+#endif
+
 #include "NmapOutputTable.h"
 #include "utils.h"

diff -urNb nmap-4.02CSW/Target.cc nmap-4.02CSW_patch/Target.cc
--- nmap-4.02CSW/Target.cc      2006-03-25 17:56:16.000000000 -0500
+++ nmap-4.02CSW_patch/Target.cc        2006-04-22 00:01:29.843750000 -0400
@@ -99,6 +99,11 @@
  ***************************************************************************/

 /* $Id: Target.cc 3224 2006-03-25 23:56:48Z fyodor $ */
+
+#ifdef WIN32
+#include "nmap_winconfig.h"
+#endif
+
 #include <dnet.h>

 #include "Target.h"
diff -urNb nmap-4.02CSW/libdnet-stripped/include/dnet_winconfig.h
nmap-4.02CSW_patch/libdnet-stripped/include/dnet_winconfig.h
--- nmap-4.02CSW/libdnet-stripped/include/dnet_winconfig.h      2005-08-07
23:58:50.000000000 -0400
+++ nmap-4.02CSW_patch/libdnet-stripped/include/dnet_winconfig.h        2006-04-21
23:39:10.546875000 -0400
@@ -276,3 +276,7 @@
 #ifndef HAVE_STRSEP
 char   *strsep(char **, const char *);
 #endif
+
+/* Without this, Windows will give us all sorts of crap about using functions
+   like strcpy() even if they are done safely */
+#define _CRT_SECURE_NO_DEPRECATE 1
diff -urNb nmap-4.02CSW/libpcre/pcre_winconfig.h
nmap-4.02CSW_patch/libpcre/pcre_winconfig.h
--- nmap-4.02CSW/libpcre/pcre_winconfig.h       2006-01-26 03:47:16.000000000 -0500
+++ nmap-4.02CSW_patch/libpcre/pcre_winconfig.h 2006-04-21
23:39:49.609375000 -0400
@@ -35,4 +35,8 @@

 // This is set by configure on other platforms -Fyodor
 #define POSIX_MALLOC_THRESHOLD 10
+
+/* Without this, Windows will give us all sorts of crap about using functions
+   like strcpy() even if they are done safely */
+#define _CRT_SECURE_NO_DEPRECATE 1
 /* End */
diff -urNb nmap-4.02CSW/mswin32/winclude.h nmap-4.02CSW_patch/mswin32/winclude.h
--- nmap-4.02CSW/mswin32/winclude.h     2005-08-23 20:02:08.000000000 -0400
+++ nmap-4.02CSW_patch/mswin32/winclude.h       2006-04-21 23:54:01.984375000 -0400
@@ -65,6 +65,8 @@
 #ifndef WINCLUDE_H
 #define WINCLUDE_H

+#include "nmap_winconfig.h"
+
 #include <stdio.h>
 #include <stdlib.h>

diff -urNb nmap-4.02CSW/nbase/nbase_winconfig.h
nmap-4.02CSW_patch/nbase/nbase_winconfig.h
--- nmap-4.02CSW/nbase/nbase_winconfig.h        2006-01-20 12:36:53.000000000 -0500
+++ nmap-4.02CSW_patch/nbase/nbase_winconfig.h  2006-04-21
23:40:28.828125000 -0400
@@ -142,6 +142,10 @@
 #define HAVE_AF_INET6 1
 #define HAVE_SOCKADDR_STORAGE 1

+/* Without this, Windows will give us all sorts of crap about using functions
+   like strcpy() even if they are done safely */
+#define _CRT_SECURE_NO_DEPRECATE 1
+
 #ifdef __GNUC__
 #define bzero(addr, num) __builtin_memset (addr, '\0', num)
 #else
diff -urNb nmap-4.02CSW/nmap_dns.cc nmap-4.02CSW_patch/nmap_dns.cc
--- nmap-4.02CSW/nmap_dns.cc    2006-03-05 18:11:42.000000000 -0500
+++ nmap-4.02CSW_patch/nmap_dns.cc      2006-04-21 23:58:23.656250000 -0400
@@ -150,6 +150,9 @@
 // * Figure out best way to estimate completion time
 //   and display it in a ScanProgressMeter

+#ifdef WIN32
+#include "nmap_winconfig.h"
+#endif

 #include <stdlib.h>
 #include <limits.h>
diff -urNb nmap-4.02CSW/nmap_winconfig.h nmap-4.02CSW_patch/nmap_winconfig.h
--- nmap-4.02CSW/nmap_winconfig.h       2006-04-02 00:27:43.000000000 -0500
+++ nmap-4.02CSW_patch/nmap_winconfig.h 2006-04-21 23:53:18.609375000 -0400
@@ -103,10 +103,13 @@

 #ifndef NMAP_WINCONFIG_H
 #define NMAP_WINCONFIG_H
-
+/* Without this, Windows will give us all sorts of crap about using functions
+   like strcpy() even if they are done safely */
+#define _CRT_SECURE_NO_DEPRECATE 1
 #define NMAP_VERSION "4.02CSW"
 #define NMAP_NAME "Nmap"
 #define NMAP_URL "http://www.insecure.org/nmap";
 #define NMAP_PLATFORM "i686-pc-windows-windows"
 #define NMAPDATADIR "c:\\nmap" /* FIXME: I really need to make this dynamic */
+
 #endif /* NMAP_WINCONFIG_H */
diff -urNb nmap-4.02CSW/scan_engine.cc nmap-4.02CSW_patch/scan_engine.cc
--- nmap-4.02CSW/scan_engine.cc 2006-03-25 17:56:16.000000000 -0500
+++ nmap-4.02CSW_patch/scan_engine.cc   2006-04-22 00:00:28.015625000 -0400
@@ -100,6 +100,10 @@

 /* $Id: scan_engine.cc 3224 2006-03-25 23:56:48Z fyodor $ */

+#ifdef WIN32
+#include "nmap_winconfig.h"
+#endif
+
 #include <dnet.h>

 #include "scan_engine.h"
diff -urNb nmap-4.02CSW/tcpip.cc nmap-4.02CSW_patch/tcpip.cc
--- nmap-4.02CSW/tcpip.cc       2006-03-25 17:56:16.000000000 -0500
+++ nmap-4.02CSW_patch/tcpip.cc 2006-04-21 23:54:45.062500000 -0400
@@ -99,7 +99,9 @@
  ***************************************************************************/

 /* $Id: tcpip.cc 3224 2006-03-25 23:56:48Z fyodor $ */
-
+#ifdef WIN32
+#include "nmap_winconfig.h"
+#endif
 #include <dnet.h>
 #include "tcpip.h"
 #include "NmapOps.h"
@@ -718,9 +720,9 @@
           "*BSD:  If you are getting device not configured, you need
to recompile your kernel with Berkeley Packet Filter support.  If you
are getting No such file or directory, try creating the device (eg cd
/dev; MAKEDEV <device>; or use mknod).\n"
           "SOLARIS:  If you are trying to scan localhost and getting
'/dev/lo0: No such file or directory', complain to Sun.  I don't think
Solaris can support advanced localhost scans.  You can probably use
\"-P0 -sT localhost\" though.\n\n", pcapdev, snaplen, promisc, to_ms,
err0r);
       } else {
-       error("pcap_open_live(%s, %d, %d, %d) FAILED. Reported error: %s. 
Will wait %d seconds then retry.", pcapdev, snaplen, promisc, to_ms,
err0r, (int) pow(5, failed));
+       error("pcap_open_live(%s, %d, %d, %d) FAILED. Reported error: %s. 
Will wait %d seconds then retry.", pcapdev, snaplen, promisc, to_ms,
err0r, (int) pow(5.0, failed));
       }
-      sleep((int) pow(5, failed));
+      sleep((int) pow(5.0, failed));
     }
   } while (!pt);


On 4/20/06, Fyodor <fyodor () insecure org> wrote:
On Thu, Apr 20, 2006 at 11:06:28PM -0400, kx wrote:
The pow(5.0, ...) patch works well.

Good.

The #define works less so, and for whatever reason, the compiler is
only respecting it when compiling nbase and nsock, but not nmap.
*sigh*  Not to mention, dnet and libpcre throw the same warnings. It
is just warnings, but it annoying.  If possible, would you mind adding
the define to the .sln file for all configurations of all projects.
Not sure on the VS 2003 interface, but here is what I do in VS2005:

I don't like changing the .sln file unless there are no other
alternatives, since they are hard to read directly and I then have to
make all of my changes to the file in Windows and then copy them
back.  So let's see if we can solve this in the .h files.  It sounds
like the nbase patch took care of nbase and nsock.  For Nmap, does
putting the #define in nmap_winconfig.h solve the problem?  For
libpcre and dnet, would you figure out the best .h file to add the
code into, test the change, and send me a diff?

We can change the .sln if we *must*, but let's give the .h files a
good try first.

Cheers,
-F

Attachment: nmap.patch.txt
Description:



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

Current thread: