Skip to content

Commit 2a1f81d

Browse files
committed
Use bool not int for boolean options
1 parent 9cfc265 commit 2a1f81d

File tree

6 files changed

+84
-85
lines changed

6 files changed

+84
-85
lines changed

NmapOps.cc

+25-25
Original file line numberDiff line numberDiff line change
@@ -297,15 +297,15 @@ void NmapOps::Initialize() {
297297
min_packet_send_rate = 0.0; /* Unset. */
298298
max_packet_send_rate = 0.0; /* Unset. */
299299
stats_interval = 0.0; /* Unset. */
300-
randomize_hosts = 0;
301-
randomize_ports = 1;
300+
randomize_hosts = false;
301+
randomize_ports = true;
302302
sendpref = PACKET_SEND_NOPREF;
303-
spoofsource = 0;
304-
fastscan = 0;
303+
spoofsource = false;
304+
fastscan = false;
305305
device[0] = '\0';
306306
ping_group_sz = PING_GROUP_SZ;
307-
nogcc = 0;
308-
generate_random_ips = 0;
307+
nogcc = false;
308+
generate_random_ips = false;
309309
reference_FPs = NULL;
310310
magic_port = 33000 + (get_random_uint() % 31000);
311311
magic_port_set = false;
@@ -328,28 +328,28 @@ void NmapOps::Initialize() {
328328
scan_delay = 0;
329329
open_only = false;
330330
scanflags = -1;
331-
defeat_rst_ratelimit = 0;
332-
defeat_icmp_ratelimit = 0;
331+
defeat_rst_ratelimit = false;
332+
defeat_icmp_ratelimit = false;
333333
resume_ip.s_addr = 0;
334-
osscan_limit = 0;
335-
osscan_guess = 0;
334+
osscan_limit = false;
335+
osscan_guess = false;
336336
numdecoys = 0;
337337
decoyturn = -1;
338-
osscan = 0;
339-
servicescan = 0;
340-
override_excludeports = 0;
338+
osscan = false;
339+
servicescan = false;
340+
override_excludeports = false;
341341
version_intensity = 7;
342342
pingtype = PINGTYPE_UNKNOWN;
343-
listscan = allowall = ackscan = bouncescan = connectscan = 0;
343+
listscan = ackscan = bouncescan = connectscan = 0;
344344
nullscan = xmasscan = fragscan = synscan = windowscan = 0;
345345
maimonscan = idlescan = finscan = udpscan = ipprotscan = 0;
346-
noportscan = noresolve = 0;
346+
noportscan = noresolve = false;
347347
sctpinitscan = 0;
348348
sctpcookieechoscan = 0;
349-
append_output = 0;
349+
append_output = false;
350350
memset(logfd, 0, sizeof(FILE *) * LOG_NUM_FILES);
351351
ttl = -1;
352-
badsum = 0;
352+
badsum = false;
353353
nmap_stdout = stdout;
354354
gettimeofday(&start_time, NULL);
355355
pTrace = vTrace = false;
@@ -379,11 +379,11 @@ void NmapOps::Initialize() {
379379
release_memory = false;
380380
topportlevel = -1;
381381
#ifndef NOLUA
382-
script = 0;
382+
script = false;
383383
scriptargs = NULL;
384-
scriptversion = 0;
385-
scripttrace = 0;
386-
scriptupdatedb = 0;
384+
scriptversion = false;
385+
scripttrace = false;
386+
scriptupdatedb = false;
387387
scripthelp = false;
388388
scripttimeout = 0;
389389
chosenScripts.clear();
@@ -546,16 +546,16 @@ administrator privileges.";
546546

547547
if (osscan && ipprotscan) {
548548
error("WARNING: Disabling OS Scan (-O) as it is incompatible with the IPProto Scan (-sO)");
549-
osscan = 0;
549+
osscan = false;
550550
}
551551

552552
if (servicescan && ipprotscan) {
553553
error("WARNING: Disabling Service Scan (-sV) as it is incompatible with the IPProto Scan (-sO)");
554-
servicescan = 0;
554+
servicescan = false;
555555
}
556556

557557
if (servicescan && noportscan)
558-
servicescan = 0;
558+
servicescan = false;
559559

560560
if (defeat_rst_ratelimit && !synscan && !openOnly()) {
561561
fatal("Option --defeat-rst-ratelimit works only with a SYN scan (-sS)");
@@ -580,7 +580,7 @@ administrator privileges.";
580580
fatal("--min-rate=%g must be less than or equal to --max-rate=%g", min_packet_send_rate, max_packet_send_rate);
581581
}
582582

583-
if (af() == AF_INET6 && (generate_random_ips|bouncescan|fragscan)) {
583+
if (af() == AF_INET6 && (generate_random_ips||bouncescan||fragscan)) {
584584
fatal("Random targets, FTP bounce scan, and fragmentation are not supported with IPv6.");
585585
}
586586

NmapOps.h

+21-22
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,14 @@ class NmapOps {
228228
float max_packet_send_rate;
229229
/* The requested auto stats printing interval, or 0.0 if unset. */
230230
float stats_interval;
231-
int randomize_hosts;
232-
int randomize_ports;
233-
int spoofsource; /* -S used */
234-
int fastscan;
231+
bool randomize_hosts;
232+
bool randomize_ports;
233+
bool spoofsource; /* -S used */
234+
bool fastscan;
235235
char device[64];
236236
int ping_group_sz;
237-
int nogcc; /* Turn off group congestion control with --nogcc */
238-
int generate_random_ips; /* -iR option */
237+
bool nogcc; /* Turn off group congestion control with --nogcc */
238+
bool generate_random_ips; /* -iR option */
239239
FingerPrintDB *reference_FPs; /* Used in the new OS scan system. */
240240
std::vector<FingerMatch> os_labels_ipv6;
241241
u16 magic_port; /* The source port set by -g or --source-port. */
@@ -308,11 +308,11 @@ class NmapOps {
308308
FIN scan into a PSH scan. Sort of a hack, but can
309309
be very useful sometimes. */
310310

311-
int defeat_rst_ratelimit; /* Solaris 9 rate-limits RSTs so scanning is very
311+
bool defeat_rst_ratelimit; /* Solaris 9 rate-limits RSTs so scanning is very
312312
slow against it. If we don't distinguish between closed and filtered ports,
313313
we can get the list of open ports very fast */
314314

315-
int defeat_icmp_ratelimit; /* If a host rate-limits ICMP responses, then scanning
315+
bool defeat_icmp_ratelimit; /* If a host rate-limits ICMP responses, then scanning
316316
is very slow against it. This option prevents Nmap to adjust timing
317317
when it changes the port's state because of ICMP response, as the latter
318318
might be rate-limited. Doing so we can get scan results faster. */
@@ -324,19 +324,18 @@ class NmapOps {
324324
to 0. */
325325

326326
// Version Detection Options
327-
int override_excludeports;
327+
bool override_excludeports;
328328
int version_intensity;
329329

330330
struct sockaddr_storage decoys[MAX_DECOYS];
331-
int osscan_limit; /* Skip OS Scan if no open or no closed TCP ports */
332-
int osscan_guess; /* Be more aggressive in guessing OS type */
331+
bool osscan_limit; /* Skip OS Scan if no open or no closed TCP ports */
332+
bool osscan_guess; /* Be more aggressive in guessing OS type */
333333
int numdecoys;
334334
int decoyturn;
335-
int osscan;
336-
int servicescan;
335+
bool osscan;
336+
bool servicescan;
337337
int pingtype;
338338
int listscan;
339-
int allowall;
340339
int fragscan; /* 0 or MTU (without IPv4 header size) */
341340
int ackscan;
342341
int bouncescan;
@@ -353,13 +352,13 @@ class NmapOps {
353352
int sctpcookieechoscan;
354353
int windowscan;
355354
int xmasscan;
356-
int noresolve;
357-
int noportscan;
358-
int append_output; /* Append to any output files rather than overwrite */
355+
bool noresolve;
356+
bool noportscan;
357+
bool append_output; /* Append to any output files rather than overwrite */
359358
FILE *logfd[LOG_NUM_FILES];
360359
FILE *nmap_stdout; /* Nmap standard output */
361360
int ttl; // Time to live
362-
int badsum;
361+
bool badsum;
363362
char *datadir;
364363
/* A map from abstract data file names like "nmap-services" and "nmap-os-db"
365364
to paths which have been requested by the user. nmap_fetchfile will return
@@ -398,12 +397,12 @@ class NmapOps {
398397
nsock_proxychain proxy_chain;
399398

400399
#ifndef NOLUA
401-
int script;
400+
bool script;
402401
char *scriptargs;
403402
char *scriptargsfile;
404-
int scriptversion;
405-
int scripttrace;
406-
int scriptupdatedb;
403+
bool scriptversion;
404+
bool scripttrace;
405+
bool scriptupdatedb;
407406
bool scripthelp;
408407
double scripttimeout;
409408
void chooseScripts(char* argument);

0 commit comments

Comments
 (0)