To reserve space for 65536 bits, allocate
65536 / (sizeof(int) * CHAR_BITS) `int's instead of 65536 / (sizeof(int) * CHAR_BITS) bytes to avoid a possible segmentation fault if ports above 16383 are specified via the -p option on a platform with 4 byte wide ints. Approved by: re (bmah) Reported by: Marco Wertejuk <wertejuk@mwcis.com>
This commit is contained in:
parent
11d9195c4a
commit
83107b499f
@ -111,7 +111,7 @@ parse_ports(const char *portspec)
|
||||
int port, end;
|
||||
|
||||
if (ports == NULL)
|
||||
if ((ports = calloc(1, 65536 / INT_BIT)) == NULL)
|
||||
if ((ports = calloc(65536 / INT_BIT, sizeof(int))) == NULL)
|
||||
err(1, "calloc()");
|
||||
p = portspec;
|
||||
while (*p != '\0') {
|
||||
|
Loading…
Reference in New Issue
Block a user