mirror of
https://github.com/ntop/n2n.git
synced 2024-09-19 16:41:11 +02:00
modified scan_address() fixing possible netmask bitlen error when -a provided IP address lacks slash (#1012)
This commit is contained in:
parent
4a2c9ef914
commit
a88236aee3
13
src/edge.c
13
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) {
|
bitlen = htobe32(bitlen2mask(bitlen));
|
||||||
// slash is present
|
inet_ntop(AF_INET, &bitlen, netmask, netmask_size);
|
||||||
|
|
||||||
// now, handle the sub-network address
|
|
||||||
sscanf(end + 1, "%u", &bitlen);
|
|
||||||
bitlen = htobe32(bitlen2mask(bitlen));
|
|
||||||
inet_ntop(AF_INET, &bitlen, netmask, netmask_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user