summaryrefslogtreecommitdiffstats
path: root/usr.bin/sockstat
diff options
context:
space:
mode:
authorrobert <robert@FreeBSD.org>2003-05-09 09:11:27 +0000
committerrobert <robert@FreeBSD.org>2003-05-09 09:11:27 +0000
commit83107b499fb9706ce31c315216bb26c0ecd6c244 (patch)
treefabaaa6fba775cbc9fcb9f398345133335c38a7a /usr.bin/sockstat
parent11d9195c4aa1ff18fa706c32bfcbc6c92f023bce (diff)
downloadFreeBSD-src-83107b499fb9706ce31c315216bb26c0ecd6c244.zip
FreeBSD-src-83107b499fb9706ce31c315216bb26c0ecd6c244.tar.gz
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>
Diffstat (limited to 'usr.bin/sockstat')
-rw-r--r--usr.bin/sockstat/sockstat.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/usr.bin/sockstat/sockstat.c b/usr.bin/sockstat/sockstat.c
index e6c7c26..1212be1 100644
--- a/usr.bin/sockstat/sockstat.c
+++ b/usr.bin/sockstat/sockstat.c
@@ -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') {
OpenPOWER on IntegriCloud