From 9879720d45f486745c1b375e0e7a376709528d40 Mon Sep 17 00:00:00 2001 From: fyodor Date: Mon, 1 Jan 2007 00:00:05 +0000 Subject: [PATCH] fix for -p used with bad ranges in ip proto scan -- from Kris Katterjohn --- nmap.cc | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/nmap.cc b/nmap.cc index e24cf9a0b..b9e132350 100644 --- a/nmap.cc +++ b/nmap.cc @@ -1902,8 +1902,12 @@ struct scan_lists *getpts(char *origexpr) { } else if (isdigit((int) *current_range)) { rangestart = strtol(current_range, &endptr, 10); - if (rangestart < 0 || rangestart > 65535) { - fatal("Ports to be scanned must be between 0 and 65535 inclusive"); + if (o.ipprotscan) { + if (rangestart < 0 || rangestart > 255) + fatal("Protocols to be scanned must be between 0 and 255 inclusive"); + } else { + if (rangestart < 0 || rangestart > 65535) + fatal("Ports to be scanned must be between 0 and 65535 inclusive"); } /* if (rangestart == 0) { error("WARNING: Scanning \"port 0\" is supported, but unusual."); @@ -1924,8 +1928,12 @@ struct scan_lists *getpts(char *origexpr) { rangeend = 65535; } else if (isdigit((int) *current_range)) { rangeend = strtol(current_range, &endptr, 10); - if (rangeend < 0 || rangeend > 65535) { - fatal("Ports to be scanned must be between 0 and 65535 inclusive"); + if (o.ipprotscan) { + if (rangeend < 0 || rangeend > 255) + fatal("Protocols to be scanned must be between 0 and 255 inclusive"); + } else { + if (rangeend < 0 || rangeend > 65535) + fatal("Ports to be scanned must be between 0 and 65535 inclusive"); } current_range = endptr; } else { @@ -1947,7 +1955,7 @@ struct scan_lists *getpts(char *origexpr) { tcpportcount++; if (range_type & SCAN_UDP_PORT) udpportcount++; - if (range_type & SCAN_PROTOCOLS && rangestart < 256) + if (range_type & SCAN_PROTOCOLS) protcount++; porttbl[rangestart] |= range_type; }