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
parent
commit
a88236aee3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      src/edge.c

9
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;
} }

Loading…
Cancel
Save