Nmap Development mailing list archives
Janitorial patch re: strtol
From: William Pursell <bill.pursell () gmail com>
Date: Fri, 07 May 2010 23:20:15 -1000
I'm new to the list, so I don't know if this sort
of patch is welcome or considered pure churn, but I was
poking around in the code and spotted an unnecessary
error check. In the following, there's no need to check
if *s is a digit; if it's not, then strtol will set
tail to it and the second check will catch it.
diff --git a/TargetGroup.cc b/TargetGroup.cc
index fdbb6e1..0155a09 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 = 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 {
- 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
- netmask = (u32) netmask_long;
- }
+ } else
+ netmask = (u32) netmask_long;
} else
netmask = 32;
resolvedname = hostexp;
--
William Pursell
_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://seclists.org/nmap-dev/
Current thread:
- Janitorial patch re: strtol William Pursell (May 08)
- Re: Janitorial patch re: strtol David Fifield (May 08)
- Re: Janitorial patch re: strtol William Pursell (May 08)
- Re: Janitorial patch re: strtol William Pursell (May 08)
- Re: Janitorial patch re: strtol David Fifield (May 08)
- Re: Janitorial patch re: strtol David Fifield (May 08)
