diff --git a/CHANGELOG b/CHANGELOG index 9d36a50ae..b72acfe89 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ #Nmap Changelog ($Id$); -*-text-*- +o Limit verbose -v and debugging -d levels to a maximum of 10. Nmap does not + use higher levels internally. [Daniel Miller] + o [NSE] bin.lua is officially deprecated. Lua 5.3, added 2 years ago in Nmap 7.25BETA2, has native support for binary data packing via string.pack and string.unpack. All existing scripts and libraries have been updated. diff --git a/NmapOps.h b/NmapOps.h index 7026cfa8e..63b17654e 100644 --- a/NmapOps.h +++ b/NmapOps.h @@ -188,7 +188,7 @@ class NmapOps { int isr00t; /* Whether we have pcap functions (can be false on Windows). */ bool have_pcap; - int debugging; + u8 debugging; bool resuming; #define PACKET_SEND_NOPREF 1 @@ -221,7 +221,7 @@ class NmapOps { void setVersionTrace(bool vt) { vTrace = vt; } bool openOnly() { return open_only; } void setOpenOnly(bool oo) { open_only = oo; } - int verbose; + u8 verbose; /* The requested minimum packet sending rate, or 0.0 if unset. */ float min_packet_send_rate; /* The requested maximum packet sending rate, or 0.0 if unset. */ diff --git a/nmap.cc b/nmap.cc index 6984c1efd..aea962726 100644 --- a/nmap.cc +++ b/nmap.cc @@ -968,6 +968,7 @@ void parse_options(int argc, char **argv) { } else if (strcmp(long_options[option_index].name, "vv") == 0) { /* Compatibility hack ... ugly */ o.verbose += 2; + if (o.verbose > 10) o.verbose = 10; } else if (strcmp(long_options[option_index].name, "ff") == 0) { o.fragscan += 16; } else if (strcmp(long_options[option_index].name, "privileged") == 0) { @@ -1061,14 +1062,15 @@ void parse_options(int argc, char **argv) { break; case 'd': if (optarg && isdigit(optarg[0])) { - o.debugging = o.verbose = atoi(optarg); + int i = atoi(optarg); + o.debugging = o.verbose = box(0, 10, i); } else { const char *p; - o.debugging++; - o.verbose++; + if (o.debugging < 10) o.debugging++; + if (o.verbose < 10) o.verbose++; for (p = optarg != NULL ? optarg : ""; *p == 'd'; p++) { - o.debugging++; - o.verbose++; + if (o.debugging < 10) o.debugging++; + if (o.verbose < 10) o.verbose++; } if (*p != '\0') fatal("Invalid argument to -d: \"%s\".", optarg); @@ -1388,7 +1390,8 @@ void parse_options(int argc, char **argv) { break; case 'v': if (optarg && isdigit(optarg[0])) { - o.verbose = atoi(optarg); + int i = atoi(optarg); + o.verbose = box(0, 10, i); if (o.verbose == 0) { o.nmap_stdout = fopen(DEVNULL, "w"); if (!o.nmap_stdout) @@ -1396,9 +1399,9 @@ void parse_options(int argc, char **argv) { } } else { const char *p; - o.verbose++; + if (o.verbose < 10) o.verbose++; for (p = optarg != NULL ? optarg : ""; *p == 'v'; p++) - o.verbose++; + if (o.verbose < 10) o.verbose++; if (*p != '\0') fatal("Invalid argument to -v: \"%s\".", optarg); } diff --git a/nmap_tty.cc b/nmap_tty.cc index 7cccc0bb1..4ba8ea5ba 100644 --- a/nmap_tty.cc +++ b/nmap_tty.cc @@ -320,14 +320,13 @@ bool keyWasPressed() // printf("You pressed key '%c'!\n", c); if (c == 'v') { - o.verbose++; + if (o.verbose < 10) o.verbose++; log_write(LOG_STDOUT, "Verbosity Increased to %d.\n", o.verbose); } else if (c == 'V') { - if (o.verbose > 0) - o.verbose--; + if (o.verbose > 0) o.verbose--; log_write(LOG_STDOUT, "Verbosity Decreased to %d.\n", o.verbose); } else if (c == 'd') { - o.debugging++; + if (o.debugging < 10) o.debugging++; log_write(LOG_STDOUT, "Debugging Increased to %d.\n", o.debugging); } else if (c == 'D') { if (o.debugging > 0) o.debugging--;