Browse Source
modified scan_address() fixing possible netmask bitlen error when -a provided IP address lacks slash (#1012)
pull/1016/head
dwj0
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
5 additions and
8 deletions
-
src/edge.c
|
@ -105,17 +105,14 @@ static int scan_address (char * ip_addr, size_t addr_size, |
|
|
if(!end) |
|
|
if(!end) |
|
|
// no slash present -- default end
|
|
|
// no slash present -- default end
|
|
|
end = s + strlen(s); |
|
|
end = s + strlen(s); |
|
|
|
|
|
else |
|
|
|
|
|
// slash is present. now, handle the sub-network address
|
|
|
|
|
|
sscanf(end + 1, "%u", &bitlen); |
|
|
|
|
|
|
|
|
strncpy(ip_addr, start, (size_t)MIN(end - start, addr_size - 1)); // ensure NULL term
|
|
|
strncpy(ip_addr, start, (size_t)MIN(end - start, addr_size - 1)); // ensure NULL term
|
|
|
|
|
|
|
|
|
if(end) { |
|
|
|
|
|
// slash is present
|
|
|
|
|
|
|
|
|
|
|
|
// now, handle the sub-network address
|
|
|
|
|
|
sscanf(end + 1, "%u", &bitlen); |
|
|
|
|
|
bitlen = htobe32(bitlen2mask(bitlen)); |
|
|
bitlen = htobe32(bitlen2mask(bitlen)); |
|
|
inet_ntop(AF_INET, &bitlen, netmask, netmask_size); |
|
|
inet_ntop(AF_INET, &bitlen, netmask, netmask_size); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return retval; |
|
|
return retval; |
|
|
} |
|
|
} |
|
|