diff --git a/CHANGELOG b/CHANGELOG index 4a6aca6a3..f7f27f872 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,9 @@ # Nmap Changelog ($Id$); -*-text-*- +o Moved the parse_long function from ncat to nbase for better reuse, + and used it to simplify netmask parsing code. This patch was + contributed by William Pursell. + o Added EPROTO to the list of known error codes in service scan. Daniel Miller reported that an EPROTO was causing Nmap to exit after sending the Sqlping probe during service scan. The error message was diff --git a/TargetGroup.cc b/TargetGroup.cc index d07a27833..cd1995492 100644 --- a/TargetGroup.cc +++ b/TargetGroup.cc @@ -187,17 +187,12 @@ int TargetGroup::parse_expr(const char * const target_expr, int af) { *s = '\0'; /* Make sure target_net is terminated before the /## */ s++; /* Point s at the netmask */ - if (!isdigit((int) (unsigned char) *s)) { + netmask_long = parse_long(s, (char**) &tail); + if (*tail != '\0' || tail == s || netmask_long < 0 || netmask_long > 32) { error("Illegal netmask value, must be /0 - /32 . Assuming /32 (one host)"); - netmask = 32; - } else { - netmask_long = strtol(s, (char**) &tail, 10); - if (*tail != '\0' || tail == s || netmask_long < 0 || netmask_long > 32) { - error("Illegal netmask value, must be /0 - /32 . Assuming /32 (one host)"); netmask = 32; - } else + } else netmask = (u32) netmask_long; - } } else netmask = 32; resolvedname = hostexp;