diff options
author | Federico G. Schwindt <fgsch@cvs.openbsd.org> | 2002-12-28 10:24:10 +0000 |
---|---|---|
committer | Federico G. Schwindt <fgsch@cvs.openbsd.org> | 2002-12-28 10:24:10 +0000 |
commit | 95de93ff1f2d2a5d181ace274d5ca0b05b4c4612 (patch) | |
tree | 50434ea3c75e9f0f146c2d99fe603dbcb7aa7fd5 /usr.bin | |
parent | 4f4ac461a5ce4b469a2fd6f768028daa0ba8efa2 (diff) |
fix calloc's. also check for errors; fixes PR/3043.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/nc/netcat.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/usr.bin/nc/netcat.c b/usr.bin/nc/netcat.c index 717e0377eb4..8361d228ff4 100644 --- a/usr.bin/nc/netcat.c +++ b/usr.bin/nc/netcat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: netcat.c,v 1.54 2002/12/13 19:53:45 aaron Exp $ */ +/* $OpenBSD: netcat.c,v 1.55 2002/12/28 10:24:09 fgsch Exp $ */ /* * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> * @@ -55,7 +55,8 @@ (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path)) #endif -#define PORT_MAX 65535 +#define PORT_MAX 65535 +#define PORT_MAX_LEN 6 /* Command Line Options */ int iflag; /* Interval Flag */ @@ -655,8 +656,10 @@ build_ports(char *p) /* Load ports sequentially */ for (cp = lo; cp <= hi; cp++) { - portlist[x] = calloc(1, PORT_MAX); - snprintf(portlist[x], PORT_MAX, "%d", cp); + portlist[x] = calloc(1, PORT_MAX_LEN); + if (portlist[x] == NULL) + err(1, NULL); + snprintf(portlist[x], PORT_MAX_LEN, "%d", cp); x++; } @@ -676,7 +679,9 @@ build_ports(char *p) hi = (int)strtoul(p, &endp, 10); if (hi <= 0 || hi > PORT_MAX || *endp != '\0') errx(1, "port range not valid"); - portlist[0] = calloc(1, PORT_MAX); + portlist[0] = calloc(1, PORT_MAX_LEN); + if (portlist[0] == NULL) + err(1, NULL); portlist[0] = p; } } |