From 9d1160511371bbcc94777a5487af1188d4dbccfd Mon Sep 17 00:00:00 2001 From: nnposter Date: Sat, 23 Sep 2017 23:24:14 +0000 Subject: [PATCH] Adds protection against dealing with excessive timer values. As a side effect it silences current MSVC compiler warning about "possible loss of data". See #995 --- nmap.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nmap.cc b/nmap.cc index 2e584c1ad..b81c62ea8 100644 --- a/nmap.cc +++ b/nmap.cc @@ -748,10 +748,10 @@ void parse_options(int argc, char **argv) { o.scripthelp = true; o.chooseScripts(optarg); } else if (optcmp(long_options[option_index].name, "script-timeout") == 0) { - l = tval2secs(optarg); - if ( l < 0 ) + d = tval2secs(optarg); + if (d < 0 || d > LONG_MAX) fatal("Bogus --script-timeout argument specified"); - delayed_options.pre_scripttimeout = l; + delayed_options.pre_scripttimeout = d; } else #endif if (optcmp(long_options[option_index].name, "max-os-tries") == 0) { @@ -1053,8 +1053,8 @@ void parse_options(int argc, char **argv) { o.adler32 = true; } else if (optcmp(long_options[option_index].name, "stats-every") == 0) { d = tval2secs(optarg); - if (d < 0) - fatal("Argument to --stats-every cannot be negative."); + if (d < 0 || d > LONG_MAX) + fatal("Bogus --stats-every argument specified"); o.stats_interval = d; } else if (optcmp(long_options[option_index].name, "disable-arp-ping") == 0) { o.implicitARPPing = false;