diff options
| -rw-r--r-- | src/usr.bin/nc/netcat.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/usr.bin/nc/netcat.c b/src/usr.bin/nc/netcat.c index 717e0377eb..8361d228ff 100644 --- a/src/usr.bin/nc/netcat.c +++ b/src/usr.bin/nc/netcat.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: netcat.c,v 1.54 2002/12/13 19:53:45 aaron Exp $ */ | 1 | /* $OpenBSD: netcat.c,v 1.55 2002/12/28 10:24:09 fgsch Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> | 3 | * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> |
| 4 | * | 4 | * |
| @@ -55,7 +55,8 @@ | |||
| 55 | (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path)) | 55 | (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path)) |
| 56 | #endif | 56 | #endif |
| 57 | 57 | ||
| 58 | #define PORT_MAX 65535 | 58 | #define PORT_MAX 65535 |
| 59 | #define PORT_MAX_LEN 6 | ||
| 59 | 60 | ||
| 60 | /* Command Line Options */ | 61 | /* Command Line Options */ |
| 61 | int iflag; /* Interval Flag */ | 62 | int iflag; /* Interval Flag */ |
| @@ -655,8 +656,10 @@ build_ports(char *p) | |||
| 655 | 656 | ||
| 656 | /* Load ports sequentially */ | 657 | /* Load ports sequentially */ |
| 657 | for (cp = lo; cp <= hi; cp++) { | 658 | for (cp = lo; cp <= hi; cp++) { |
| 658 | portlist[x] = calloc(1, PORT_MAX); | 659 | portlist[x] = calloc(1, PORT_MAX_LEN); |
| 659 | snprintf(portlist[x], PORT_MAX, "%d", cp); | 660 | if (portlist[x] == NULL) |
| 661 | err(1, NULL); | ||
| 662 | snprintf(portlist[x], PORT_MAX_LEN, "%d", cp); | ||
| 660 | x++; | 663 | x++; |
| 661 | } | 664 | } |
| 662 | 665 | ||
| @@ -676,7 +679,9 @@ build_ports(char *p) | |||
| 676 | hi = (int)strtoul(p, &endp, 10); | 679 | hi = (int)strtoul(p, &endp, 10); |
| 677 | if (hi <= 0 || hi > PORT_MAX || *endp != '\0') | 680 | if (hi <= 0 || hi > PORT_MAX || *endp != '\0') |
| 678 | errx(1, "port range not valid"); | 681 | errx(1, "port range not valid"); |
| 679 | portlist[0] = calloc(1, PORT_MAX); | 682 | portlist[0] = calloc(1, PORT_MAX_LEN); |
| 683 | if (portlist[0] == NULL) | ||
| 684 | err(1, NULL); | ||
| 680 | portlist[0] = p; | 685 | portlist[0] = p; |
| 681 | } | 686 | } |
| 682 | } | 687 | } |
