Skip to content

Commit

Permalink
Merging over from /nmap-exp/kris/assert-testing
Browse files Browse the repository at this point in the history
Ensuring the safety of assert() calls by keeping NDEBUG undefined throughout
Nmap, Nbase and Nsock.

I've tested this on Linux and Windows XP without problems.  On Windows I've
removed the definitions of _DEBUG and NDEBUG from the *.vcproj files.
  • Loading branch information
kris committed May 3, 2008
1 parent 38fd81d commit 85edc7a
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 27 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Nmap Changelog ($Id$); -*-text-*-

o Since assert() calls are used for various security-related tests,
their safety is now ensured by keeping NDEBUG undefined throughout
Nmap, Nbase and Nsock. [Kris]

Nmap 4.62 [5/3/08]

o Added a new --min-rate option that allows specifying a minimum rate
Expand Down
2 changes: 1 addition & 1 deletion NmapOutputTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
#ifndef NMAPOUTPUTTABLE_H
#define NMAPOUTPUTTABLE_H

#include <assert.h>
#include "nmap.h"

#ifndef __attribute__
#define __attribute__(args)
Expand Down
4 changes: 2 additions & 2 deletions libdnet-stripped/libdnet-stripped.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
AdditionalOptions="/D &quot;_CRT_SECURE_NO_DEPRECATE&quot;"
Optimization="0"
AdditionalIncludeDirectories="include;&quot;..\mswin32\pcap-include&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
PreprocessorDefinitions="WIN32;_LIB"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
Expand Down Expand Up @@ -108,7 +108,7 @@
Name="VCCLCompilerTool"
AdditionalOptions="/D &quot;_CRT_SECURE_NO_DEPRECATE&quot;"
AdditionalIncludeDirectories="include;&quot;..\mswin32\pcap-include&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
PreprocessorDefinitions="WIN32;_LIB"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
Expand Down
4 changes: 2 additions & 2 deletions liblua/liblua.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
UseUnicodeResponseFiles="false"
AdditionalOptions="/D &quot;_CRT_SECURE_NO_DEPRECATE&quot;"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
PreprocessorDefinitions="WIN32;_LIB"
MinimalRebuild="true"
ExceptionHandling="0"
BasicRuntimeChecks="0"
Expand Down Expand Up @@ -114,7 +114,7 @@
UseUnicodeResponseFiles="false"
AdditionalOptions="/D &quot;_CRT_SECURE_NO_DEPRECATE&quot;"
WholeProgramOptimization="false"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
PreprocessorDefinitions="WIN32;_LIB"
MinimalRebuild="false"
ExceptionHandling="0"
BasicRuntimeChecks="0"
Expand Down
4 changes: 2 additions & 2 deletions libpcre/libpcre.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
PreprocessorDefinitions="WIN32;_LIB"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
Expand Down Expand Up @@ -104,7 +104,7 @@
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
PreprocessorDefinitions="WIN32;_LIB"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
Expand Down
14 changes: 2 additions & 12 deletions mswin32/nmap.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\liblua;.;..;../nbase;../libpcre;winip;..\nsock\include;&quot;pcap-include&quot;;&quot;..\libdnet-stripped\include&quot;"
PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE"
PreprocessorDefinitions="WIN32;_CONSOLE"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
Expand All @@ -61,11 +61,6 @@
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
Expand Down Expand Up @@ -142,7 +137,7 @@
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories=".;..;../liblua;../nbase;../libpcre;winip;..\nsock\include;&quot;pcap-include&quot;;&quot;..\libdnet-stripped\include&quot;"
PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE"
PreprocessorDefinitions="WIN32;_CONSOLE"
StringPooling="true"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
Expand All @@ -157,11 +152,6 @@
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
Expand Down
3 changes: 3 additions & 0 deletions nmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ void *realloc();
#include <arpa/inet.h>
#endif

/* Keep assert() defined for security reasons */
#undef NDEBUG

#include <math.h>
#include <assert.h>

Expand Down
4 changes: 2 additions & 2 deletions nselib-bin/nse_bitlib.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\liblua"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;NSE_BITLIB_EXPORTS;WIN32;LUA_BUILD_AS_DLL;LUA_LIB"
PreprocessorDefinitions="WIN32;_WINDOWS;_USRDLL;NSE_BITLIB_EXPORTS;WIN32;LUA_BUILD_AS_DLL;LUA_LIB"
MinimalRebuild="false"
ExceptionHandling="0"
BasicRuntimeChecks="0"
Expand Down Expand Up @@ -120,7 +120,7 @@
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\liblua"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;NSE_BITLIB_EXPORTS;WIN32;LUA_BUILD_AS_DLL;LUA_LIB"
PreprocessorDefinitions="WIN32;_WINDOWS;_USRDLL;NSE_BITLIB_EXPORTS;WIN32;LUA_BUILD_AS_DLL;LUA_LIB"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
Expand Down
4 changes: 0 additions & 4 deletions service_scan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,6 @@
namespace std {};
using namespace std;

// Because this file uses assert()s for some security checking, we can't
// have anyone turning off debugging.
#undef NDEBUG

extern NmapOps o;

// Details on a particular service (open port) we are trying to match
Expand Down
3 changes: 1 addition & 2 deletions utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include "nmap.h"
#ifdef WIN32
#include "mswin32\winclude.h"
#else
Expand All @@ -117,7 +118,6 @@
#include <netinet/in.h>
#endif

#include <assert.h>
#include <sys/mman.h>
#include "nmap_config.h"
#endif
Expand All @@ -140,7 +140,6 @@
#include "nbase.h"

#include "nmap_error.h"
#include "nmap.h"
#include "global_structures.h"

/* Arithmatic difference modulo 2^32 */
Expand Down

0 comments on commit 85edc7a

Please sign in to comment.