diff options
| -rw-r--r-- | src/usr.bin/nc/netcat.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/usr.bin/nc/netcat.c b/src/usr.bin/nc/netcat.c index a64d156379..6c516428fd 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.30 2001/06/27 03:14:28 smart Exp $ */ | 1 | /* $OpenBSD: netcat.c,v 1.31 2001/06/27 07:23:58 ericj Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> | 3 | * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> |
| 4 | * | 4 | * |
| @@ -48,6 +48,8 @@ | |||
| 48 | #include <string.h> | 48 | #include <string.h> |
| 49 | #include <unistd.h> | 49 | #include <unistd.h> |
| 50 | 50 | ||
| 51 | #define PORT_MAX 65535 | ||
| 52 | |||
| 51 | /* Command Line Options */ | 53 | /* Command Line Options */ |
| 52 | int iflag; /* Interval Flag */ | 54 | int iflag; /* Interval Flag */ |
| 53 | int kflag; /* More than one connect */ | 55 | int kflag; /* More than one connect */ |
| @@ -63,10 +65,9 @@ int zflag; /* Port Scan Flag */ | |||
| 63 | 65 | ||
| 64 | int timeout; | 66 | int timeout; |
| 65 | int family = AF_UNSPEC; | 67 | int family = AF_UNSPEC; |
| 66 | char *portlist[65535]; | 68 | char *portlist[PORT_MAX]; |
| 67 | 69 | ||
| 68 | ssize_t atomicio __P((ssize_t (*)(), int, void *, size_t)); | 70 | ssize_t atomicio __P((ssize_t (*)(), int, void *, size_t)); |
| 69 | |||
| 70 | void atelnet __P((int, unsigned char *, unsigned int)); | 71 | void atelnet __P((int, unsigned char *, unsigned int)); |
| 71 | void build_ports __P((char *)); | 72 | void build_ports __P((char *)); |
| 72 | void help __P((void)); | 73 | void help __P((void)); |
| @@ -503,10 +504,10 @@ build_ports(p) | |||
| 503 | 504 | ||
| 504 | /* Make sure the ports are in order: lowest->highest */ | 505 | /* Make sure the ports are in order: lowest->highest */ |
| 505 | hi = (int)strtoul(n, &endp, 10); | 506 | hi = (int)strtoul(n, &endp, 10); |
| 506 | if (hi <= 0 || hi > 65535 || *endp != '\0') | 507 | if (hi <= 0 || hi > PORT_MAX || *endp != '\0') |
| 507 | errx(1, "port range not valid"); | 508 | errx(1, "port range not valid"); |
| 508 | lo = (int)strtoul(p, &endp, 10); | 509 | lo = (int)strtoul(p, &endp, 10); |
| 509 | if (lo <= 0 || lo > 65535 || *endp != '\0') | 510 | if (lo <= 0 || lo > PORT_MAX || *endp != '\0') |
| 510 | errx(1, "port range not valid"); | 511 | errx(1, "port range not valid"); |
| 511 | 512 | ||
| 512 | if (lo > hi) { | 513 | if (lo > hi) { |
| @@ -517,7 +518,7 @@ build_ports(p) | |||
| 517 | 518 | ||
| 518 | /* Load ports sequentially */ | 519 | /* Load ports sequentially */ |
| 519 | for (cp = lo; cp <= hi; cp++) { | 520 | for (cp = lo; cp <= hi; cp++) { |
| 520 | portlist[x] = malloc(sizeof(65535)); | 521 | portlist[x] = malloc(sizeof(PORT_MAX)); |
| 521 | sprintf(portlist[x], "%d", cp); | 522 | sprintf(portlist[x], "%d", cp); |
| 522 | x++; | 523 | x++; |
| 523 | } | 524 | } |
| @@ -536,9 +537,9 @@ build_ports(p) | |||
| 536 | } | 537 | } |
| 537 | } else { | 538 | } else { |
| 538 | hi = (int)strtoul(p, &endp, 10); | 539 | hi = (int)strtoul(p, &endp, 10); |
| 539 | if (hi <= 0 || hi > 65535 || *endp != '\0') | 540 | if (hi <= 0 || hi > PORT_MAX || *endp != '\0') |
| 540 | errx(1, "port range not valid"); | 541 | errx(1, "port range not valid"); |
| 541 | portlist[0] = malloc(sizeof(65535)); | 542 | portlist[0] = malloc(sizeof(PORT_MAX)); |
| 542 | portlist[0] = p; | 543 | portlist[0] = p; |
| 543 | } | 544 | } |
| 544 | } | 545 | } |
