mirror of
https://github.com/nmap/nmap.git
synced 2025-12-07 13:11:28 +00:00
Make it a warning (not a fatal error) when there's a problem with an IPv4 spec.
This is the way it worked for IPv6 (with the exception of a slash in an IPv6 address, which has also been made into a warning)--warn about the bogus specification and carry on with the other targets. The main use for this is preventing the whole scan from being stopped when a bad specification appears in a hostgroup after the first.
This commit is contained in:
@@ -140,8 +140,10 @@ int TargetGroup::parse_expr(const char *target_expr, int af) {
|
|||||||
|
|
||||||
if (af == AF_INET) {
|
if (af == AF_INET) {
|
||||||
|
|
||||||
if (strchr(hostexp, ':'))
|
if (strchr(hostexp, ':')) {
|
||||||
fatal("Invalid host expression: %s -- colons only allowed in IPv6 addresses, and then you need the -6 switch", hostexp);
|
error("Invalid host expression: %s -- colons only allowed in IPv6 addresses, and then you need the -6 switch", hostexp);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*struct in_addr current_in;*/
|
/*struct in_addr current_in;*/
|
||||||
addy[0] = addy[1] = addy[2] = addy[3] = addy[4] = NULL;
|
addy[0] = addy[1] = addy[2] = addy[3] = addy[4] = NULL;
|
||||||
@@ -232,11 +234,16 @@ int TargetGroup::parse_expr(const char *target_expr, int af) {
|
|||||||
*r = '\0';
|
*r = '\0';
|
||||||
addy[i] = r + 1;
|
addy[i] = r + 1;
|
||||||
}
|
}
|
||||||
else if (*r != '*' && *r != ',' && *r != '-' && !isdigit((int) (unsigned char) *r))
|
else if (*r != '*' && *r != ',' && *r != '-' && !isdigit((int) (unsigned char) *r)) {
|
||||||
fatal("Invalid character in host specification. Note in particular that square brackets [] are no longer allowed. They were redundant and can simply be removed.");
|
error("Invalid character in host specification: %s. Note in particular that square brackets [] are no longer allowed. They were redundant and can simply be removed.", target_expr);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
r++;
|
r++;
|
||||||
}
|
}
|
||||||
if (i != 3) fatal("Invalid target host specification: %s", target_expr);
|
if (i != 3) {
|
||||||
|
error("Invalid target host specification: %s", target_expr);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
for(i=0; i < 4; i++) {
|
for(i=0; i < 4; i++) {
|
||||||
j=0;
|
j=0;
|
||||||
@@ -256,10 +263,14 @@ int TargetGroup::parse_expr(const char *target_expr, int af) {
|
|||||||
}
|
}
|
||||||
/* if (o.debugging > 2)
|
/* if (o.debugging > 2)
|
||||||
* log_write(LOG_STDOUT, "The first host is %d, and the last one is %d\n", start, end); */
|
* log_write(LOG_STDOUT, "The first host is %d, and the last one is %d\n", start, end); */
|
||||||
if (start < 0 || start > end || start > 255 || end > 255)
|
if (start < 0 || start > end || start > 255 || end > 255) {
|
||||||
fatal("Your host specifications are illegal!");
|
error("Your host specifications are illegal!");
|
||||||
if (j + (end - start) > 255)
|
return 1;
|
||||||
fatal("Your host specifications are illegal!");
|
}
|
||||||
|
if (j + (end - start) > 255) {
|
||||||
|
error("Your host specifications are illegal!");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
for(k=start; k <= end; k++)
|
for(k=start; k <= end; k++)
|
||||||
addresses[i][j++] = k;
|
addresses[i][j++] = k;
|
||||||
last[i] = j-1;
|
last[i] = j-1;
|
||||||
@@ -281,7 +292,9 @@ int TargetGroup::parse_expr(const char *target_expr, int af) {
|
|||||||
|
|
||||||
assert(af == AF_INET6);
|
assert(af == AF_INET6);
|
||||||
if (strchr(hostexp, '/')) {
|
if (strchr(hostexp, '/')) {
|
||||||
fatal("Invalid host expression: %s -- slash not allowed. IPv6 addresses can currently only be specified individually", hostexp);
|
error("Invalid host expression: %s -- slash not allowed. IPv6 addresses can currently only be specified individually", hostexp);
|
||||||
|
free(hostexp);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
resolvedname = hostexp;
|
resolvedname = hostexp;
|
||||||
if (strchr(hostexp, ':') == NULL)
|
if (strchr(hostexp, ':') == NULL)
|
||||||
|
|||||||
Reference in New Issue
Block a user