diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/usr.bin/nc/netcat.c | 457 |
1 files changed, 195 insertions, 262 deletions
diff --git a/src/usr.bin/nc/netcat.c b/src/usr.bin/nc/netcat.c index 523c2d7bf5..a8faf83917 100644 --- a/src/usr.bin/nc/netcat.c +++ b/src/usr.bin/nc/netcat.c | |||
| @@ -1,29 +1,29 @@ | |||
| 1 | /* Netcat 1.10 RELEASE 960320 | 1 | /* Netcat 1.10 RELEASE 960320 |
| 2 | 2 | * | |
| 3 | A damn useful little "backend" utility begun 950915 or thereabouts, | 3 | * A damn useful little "backend" utility begun 950915 or thereabouts, |
| 4 | as *Hobbit*'s first real stab at some sockets programming. Something that | 4 | * as *Hobbit*'s first real stab at some sockets programming. Something that |
| 5 | should have and indeed may have existed ten years ago, but never became a | 5 | * should have and indeed may have existed ten years ago, but never became a |
| 6 | standard Unix utility. IMHO, "nc" could take its place right next to cat, | 6 | * standard Unix utility. IMHO, "nc" could take its place right next to cat, |
| 7 | cp, rm, mv, dd, ls, and all those other cryptic and Unix-like things. | 7 | * cp, rm, mv, dd, ls, and all those other cryptic and Unix-like things. |
| 8 | 8 | * | |
| 9 | Read the README for the whole story, doc, applications, etc. | 9 | * Read the README for the whole story, doc, applications, etc. |
| 10 | 10 | * | |
| 11 | Layout: | 11 | * Layout: |
| 12 | conditional includes: | 12 | * conditional includes: |
| 13 | includes: | 13 | * includes: |
| 14 | handy defines: | 14 | * handy defines: |
| 15 | globals: | 15 | * globals: |
| 16 | malloced globals: | 16 | * malloced globals: |
| 17 | cmd-flag globals: | 17 | * cmd-flag globals: |
| 18 | support routines: | 18 | * support routines: |
| 19 | readwrite select loop: | 19 | * readwrite select loop: |
| 20 | main: | 20 | * main: |
| 21 | 21 | * | |
| 22 | bluesky: | 22 | * bluesky: |
| 23 | parse ranges of IP address as well as ports, perhaps | 23 | * parse ranges of IP address as well as ports, perhaps |
| 24 | RAW mode! | 24 | * RAW mode! |
| 25 | backend progs to grab a pty and look like a real telnetd?! | 25 | * backend progs to grab a pty and look like a real telnetd?! |
| 26 | backend progs to do various encryption modes??!?! | 26 | * backend progs to do various encryption modes??!?! |
| 27 | */ | 27 | */ |
| 28 | 28 | ||
| 29 | #include "generic.h" /* same as with L5, skey, etc */ | 29 | #include "generic.h" /* same as with L5, skey, etc */ |
| @@ -32,26 +32,24 @@ | |||
| 32 | for your own architecture [and please send diffs...]: */ | 32 | for your own architecture [and please send diffs...]: */ |
| 33 | /* #undef _POSIX_SOURCE /* might need this for something? */ | 33 | /* #undef _POSIX_SOURCE /* might need this for something? */ |
| 34 | #define HAVE_BIND /* ASSUMPTION -- seems to work everywhere! */ | 34 | #define HAVE_BIND /* ASSUMPTION -- seems to work everywhere! */ |
| 35 | #define HAVE_HELP /* undefine if you dont want the help text */ | ||
| 36 | 35 | ||
| 37 | #ifdef HAVE_STDLIB_H | 36 | #include <sys/types.h> |
| 38 | #include <stdlib.h> | 37 | #include <sys/time.h> |
| 39 | #else | ||
| 40 | #include <malloc.h> | ||
| 41 | #endif | ||
| 42 | #ifdef HAVE_SELECT_H /* random SV variants need this */ | ||
| 43 | #include <sys/select.h> | 38 | #include <sys/select.h> |
| 44 | #endif | 39 | #include <sys/socket.h> |
| 45 | #ifdef HAVE_UNISTD_H | 40 | #include <netinet/in.h> |
| 41 | #include <netinet/in_systm.h> | ||
| 42 | #include <netinet/ip.h> | ||
| 43 | #include <arpa/inet.h> | ||
| 44 | #include <netdb.h> /* hostent, gethostby*, getservby* */ | ||
| 45 | #include <stdio.h> | ||
| 46 | #include <string.h> | ||
| 47 | #include <errno.h> | ||
| 48 | #include <setjmp.h> | ||
| 49 | #include <signal.h> | ||
| 50 | #include <fcntl.h> | ||
| 51 | #include <stdlib.h> | ||
| 46 | #include <unistd.h> | 52 | #include <unistd.h> |
| 47 | #endif | ||
| 48 | |||
| 49 | /* have to do this *before* including types.h. xxx: Linux still has it wrong */ | ||
| 50 | #ifdef FD_SETSIZE /* should be in types.h, butcha never know. */ | ||
| 51 | #undef FD_SETSIZE /* if we ever need more than 16 active */ | ||
| 52 | #endif /* fd's, something is horribly wrong! */ | ||
| 53 | #define FD_SETSIZE 16 /* <-- this'll give us a long anyways, wtf */ | ||
| 54 | #include <sys/types.h> /* *now* do it. Sigh, this is broken */ | ||
| 55 | 53 | ||
| 56 | #ifdef HAVE_RANDOM /* aficionados of ?rand48() should realize */ | 54 | #ifdef HAVE_RANDOM /* aficionados of ?rand48() should realize */ |
| 57 | #define SRAND srandom /* that this doesn't need *strong* random */ | 55 | #define SRAND srandom /* that this doesn't need *strong* random */ |
| @@ -61,58 +59,28 @@ | |||
| 61 | #define RAND rand | 59 | #define RAND rand |
| 62 | #endif /* HAVE_RANDOM */ | 60 | #endif /* HAVE_RANDOM */ |
| 63 | 61 | ||
| 64 | /* includes: */ | ||
| 65 | #include <sys/time.h> /* timeval, time_t */ | ||
| 66 | #include <setjmp.h> /* jmp_buf et al */ | ||
| 67 | #include <sys/socket.h> /* basics, SO_ and AF_ defs, sockaddr, ... */ | ||
| 68 | #include <netinet/in.h> /* sockaddr_in, htons, in_addr */ | ||
| 69 | #include <netinet/in_systm.h> /* misc crud that netinet/ip.h references */ | ||
| 70 | #include <netinet/ip.h> /* IPOPT_LSRR, header stuff */ | ||
| 71 | #include <netdb.h> /* hostent, gethostby*, getservby* */ | ||
| 72 | #include <arpa/inet.h> /* inet_ntoa */ | ||
| 73 | #include <stdio.h> | ||
| 74 | #include <string.h> /* strcpy, strchr, yadda yadda */ | ||
| 75 | #include <errno.h> | ||
| 76 | #include <signal.h> | ||
| 77 | #include <fcntl.h> /* O_WRONLY et al */ | ||
| 78 | |||
| 79 | /* handy stuff: */ | ||
| 80 | #define SA struct sockaddr /* socket overgeneralization braindeath */ | ||
| 81 | #define SAI struct sockaddr_in /* ... whoever came up with this model */ | ||
| 82 | #define IA struct in_addr /* ... should be taken out and shot, */ | ||
| 83 | /* ... not that TLI is any better. sigh.. */ | ||
| 84 | #define SLEAZE_PORT 31337 /* for UDP-scan RTT trick, change if ya want */ | 62 | #define SLEAZE_PORT 31337 /* for UDP-scan RTT trick, change if ya want */ |
| 85 | #define USHORT unsigned short /* use these for options an' stuff */ | ||
| 86 | #define BIGSIZ 8192 /* big buffers */ | 63 | #define BIGSIZ 8192 /* big buffers */ |
| 87 | 64 | ||
| 88 | #ifndef INADDR_NONE | 65 | struct host_info { |
| 89 | #define INADDR_NONE 0xffffffff | ||
| 90 | #endif | ||
| 91 | |||
| 92 | struct host_poop { | ||
| 93 | char name[MAXHOSTNAMELEN]; /* dns name */ | 66 | char name[MAXHOSTNAMELEN]; /* dns name */ |
| 94 | char addrs[8][24]; /* ascii-format IP addresses */ | 67 | char addrs[8][24]; /* ascii-format IP addresses */ |
| 95 | struct in_addr iaddrs[8]; /* real addresses: in_addr.s_addr: | 68 | struct in_addr iaddrs[8]; /* real addresses: in_addr.s_addr: |
| 96 | * ulong */ | 69 | * ulong */ |
| 97 | }; | 70 | }; |
| 98 | #define HINF struct host_poop | ||
| 99 | 71 | ||
| 100 | struct port_poop { | 72 | struct port_info { |
| 101 | char name[64]; /* name in /etc/services */ | 73 | char name[64]; /* name in /etc/services */ |
| 102 | char anum[8]; /* ascii-format number */ | 74 | char anum[8]; /* ascii-format number */ |
| 103 | USHORT num; /* real host-order number */ | 75 | u_short num; /* real host-order number */ |
| 104 | }; | 76 | }; |
| 105 | #define PINF struct port_poop | ||
| 106 | 77 | ||
| 107 | /* globals: */ | 78 | /* globals: */ |
| 108 | jmp_buf jbuf; /* timer crud */ | 79 | jmp_buf jbuf; /* timer crud */ |
| 109 | int jval = 0; /* timer crud */ | 80 | int jval = 0; /* timer crud */ |
| 110 | int netfd = -1; | 81 | int netfd = -1; |
| 111 | int ofd = 0; /* hexdump output fd */ | 82 | int ofd = 0; /* hexdump output fd */ |
| 112 | static char unknown[] = "(UNKNOWN)"; | 83 | |
| 113 | static char p_tcp[] = "tcp"; /* for getservby* */ | ||
| 114 | static char p_udp[] = "udp"; | ||
| 115 | #ifdef HAVE_BIND | ||
| 116 | extern int h_errno; | 84 | extern int h_errno; |
| 117 | /* stolen almost wholesale from bsd herror.c */ | 85 | /* stolen almost wholesale from bsd herror.c */ |
| 118 | static char *h_errs[] = { | 86 | static char *h_errs[] = { |
| @@ -122,12 +90,10 @@ static char *h_errs[] = { | |||
| 122 | "Unknown server error", /* 3 NO_RECOVERY */ | 90 | "Unknown server error", /* 3 NO_RECOVERY */ |
| 123 | "No address associated with name", /* 4 NO_ADDRESS */ | 91 | "No address associated with name", /* 4 NO_ADDRESS */ |
| 124 | }; | 92 | }; |
| 125 | #else | 93 | |
| 126 | int h_errno; /* just so we *do* have it available */ | ||
| 127 | #endif /* HAVE_BIND */ | ||
| 128 | int gatesidx = 0; /* LSRR hop count */ | 94 | int gatesidx = 0; /* LSRR hop count */ |
| 129 | int gatesptr = 4; /* initial LSRR pointer, settable */ | 95 | int gatesptr = 4; /* initial LSRR pointer, settable */ |
| 130 | USHORT Single = 1; /* zero if scanning */ | 96 | u_short Single = 1; /* zero if scanning */ |
| 131 | unsigned int insaved = 0; /* stdin-buffer size for multi-mode */ | 97 | unsigned int insaved = 0; /* stdin-buffer size for multi-mode */ |
| 132 | unsigned int wrote_out = 0; /* total stdout bytes */ | 98 | unsigned int wrote_out = 0; /* total stdout bytes */ |
| 133 | unsigned int wrote_net = 0; /* total net bytes */ | 99 | unsigned int wrote_net = 0; /* total net bytes */ |
| @@ -135,30 +101,28 @@ static char wrote_txt[] = " sent %d, rcvd %d"; | |||
| 135 | static char hexnibs[20] = "0123456789abcdef "; | 101 | static char hexnibs[20] = "0123456789abcdef "; |
| 136 | 102 | ||
| 137 | /* will malloc up the following globals: */ | 103 | /* will malloc up the following globals: */ |
| 138 | struct timeval *timer1 = NULL; | 104 | struct timeval timer1, timer2; |
| 139 | struct timeval *timer2 = NULL; | 105 | struct sockaddr_in *lclend = NULL; /* sockaddr_in structs */ |
| 140 | SAI *lclend = NULL; /* sockaddr_in structs */ | 106 | struct sockaddr_in *remend = NULL; |
| 141 | SAI *remend = NULL; | 107 | struct host_info **gates = NULL; /* LSRR hop hostpoop */ |
| 142 | HINF **gates = NULL; /* LSRR hop hostpoop */ | ||
| 143 | char *optbuf = NULL; /* LSRR or sockopts */ | 108 | char *optbuf = NULL; /* LSRR or sockopts */ |
| 144 | char *bigbuf_in; /* data buffers */ | 109 | char *bigbuf_in; /* data buffers */ |
| 145 | char *bigbuf_net; | 110 | char *bigbuf_net; |
| 146 | fd_set *ding1; /* for select loop */ | 111 | fd_set fds1, fds2; |
| 147 | fd_set *ding2; | 112 | struct port_info *portpoop = NULL; /* for getportpoop / getservby* */ |
| 148 | PINF *portpoop = NULL; /* for getportpoop / getservby* */ | ||
| 149 | unsigned char *stage = NULL; /* hexdump line buffer */ | 113 | unsigned char *stage = NULL; /* hexdump line buffer */ |
| 150 | 114 | ||
| 151 | /* global cmd flags: */ | 115 | /* global cmd flags: */ |
| 152 | USHORT o_alla = 0; | 116 | u_short o_alla = 0; |
| 153 | unsigned int o_interval = 0; | 117 | unsigned int o_interval = 0; |
| 154 | USHORT o_listen = 0; | 118 | u_short o_listen = 0; |
| 155 | USHORT o_nflag = 0; | 119 | u_short o_nflag = 0; |
| 156 | USHORT o_wfile = 0; | 120 | u_short o_wfile = 0; |
| 157 | USHORT o_random = 0; | 121 | u_short o_random = 0; |
| 158 | USHORT o_udpmode = 0; | 122 | u_short o_udpmode = 0; |
| 159 | USHORT o_verbose = 0; | 123 | u_short o_verbose = 0; |
| 160 | unsigned int o_wait = 0; | 124 | unsigned int o_wait = 0; |
| 161 | USHORT o_zero = 0; | 125 | u_short o_zero = 0; |
| 162 | /* o_tn in optional section */ | 126 | /* o_tn in optional section */ |
| 163 | 127 | ||
| 164 | /* Debug macro: squirt whatever message and sleep a bit so we can see it go | 128 | /* Debug macro: squirt whatever message and sleep a bit so we can see it go |
| @@ -201,7 +165,7 @@ holler(str, p1, p2, p3, p4, p5, p6) | |||
| 201 | fprintf(stderr, "\n"); | 165 | fprintf(stderr, "\n"); |
| 202 | fflush(stderr); | 166 | fflush(stderr); |
| 203 | } | 167 | } |
| 204 | } /* holler */ | 168 | } |
| 205 | 169 | ||
| 206 | /* bail : | 170 | /* bail : |
| 207 | error-exit handler, callable from anywhere */ | 171 | error-exit handler, callable from anywhere */ |
| @@ -213,9 +177,8 @@ bail(str, p1, p2, p3, p4, p5, p6) | |||
| 213 | o_verbose = 1; | 177 | o_verbose = 1; |
| 214 | holler(str, p1, p2, p3, p4, p5, p6); | 178 | holler(str, p1, p2, p3, p4, p5, p6); |
| 215 | close(netfd); | 179 | close(netfd); |
| 216 | sleep(1); | ||
| 217 | exit(1); | 180 | exit(1); |
| 218 | } /* bail */ | 181 | } |
| 219 | 182 | ||
| 220 | /* catch : | 183 | /* catch : |
| 221 | no-brainer interrupt handler */ | 184 | no-brainer interrupt handler */ |
| @@ -255,23 +218,7 @@ arm(num, secs) | |||
| 255 | alarm(secs); | 218 | alarm(secs); |
| 256 | jval = num; | 219 | jval = num; |
| 257 | } /* if secs */ | 220 | } /* if secs */ |
| 258 | } /* arm */ | 221 | } |
| 259 | |||
| 260 | /* Hmalloc : | ||
| 261 | malloc up what I want, rounded up to *4, and pre-zeroed. Either succeeds | ||
| 262 | or bails out on its own, so that callers don't have to worry about it. */ | ||
| 263 | char * | ||
| 264 | Hmalloc(size) | ||
| 265 | unsigned int size; | ||
| 266 | { | ||
| 267 | unsigned int s = (size + 4) & 0xfffffffc; /* 4GB?! */ | ||
| 268 | char *p = malloc(s); | ||
| 269 | if (p != NULL) | ||
| 270 | memset(p, 0, s); | ||
| 271 | else | ||
| 272 | bail("Hmalloc %d failed", s); | ||
| 273 | return (p); | ||
| 274 | } /* Hmalloc */ | ||
| 275 | 222 | ||
| 276 | /* findline : | 223 | /* findline : |
| 277 | find the next newline in a buffer; return inclusive size of that "line", | 224 | find the next newline in a buffer; return inclusive size of that "line", |
| @@ -300,16 +247,16 @@ findline(buf, siz) | |||
| 300 | } /* for */ | 247 | } /* for */ |
| 301 | Debug(("findline returning whole thing: %d", siz)) | 248 | Debug(("findline returning whole thing: %d", siz)) |
| 302 | return (siz); | 249 | return (siz); |
| 303 | } /* findline */ | 250 | } |
| 304 | 251 | ||
| 305 | /* comparehosts : | 252 | /* comparehosts : |
| 306 | cross-check the host_poop we have so far against new gethostby*() info, | 253 | cross-check the host_info we have so far against new gethostby*() info, |
| 307 | and holler about mismatches. Perhaps gratuitous, but it can't hurt to | 254 | and holler about mismatches. Perhaps gratuitous, but it can't hurt to |
| 308 | point out when someone's DNS is fukt. Returns 1 if mismatch, in case | 255 | point out when someone's DNS is fukt. Returns 1 if mismatch, in case |
| 309 | someone else wants to do something about it. */ | 256 | someone else wants to do something about it. */ |
| 310 | int | 257 | int |
| 311 | comparehosts(poop, hp) | 258 | comparehosts(poop, hp) |
| 312 | HINF *poop; | 259 | struct host_info *poop; |
| 313 | struct hostent *hp; | 260 | struct hostent *hp; |
| 314 | { | 261 | { |
| 315 | errno = 0; | 262 | errno = 0; |
| @@ -320,21 +267,21 @@ comparehosts(poop, hp) | |||
| 320 | } | 267 | } |
| 321 | return (0); | 268 | return (0); |
| 322 | /* ... do we need to do anything over and above that?? */ | 269 | /* ... do we need to do anything over and above that?? */ |
| 323 | } /* comparehosts */ | 270 | } |
| 324 | 271 | ||
| 325 | /* gethostpoop : | 272 | /* gethostpoop : |
| 326 | resolve a host 8 ways from sunday; return a new host_poop struct with its | 273 | resolve a host 8 ways from sunday; return a new host_info struct with its |
| 327 | info. The argument can be a name or [ascii] IP address; it will try its | 274 | info. The argument can be a name or [ascii] IP address; it will try its |
| 328 | damndest to deal with it. "numeric" governs whether we do any DNS at all, | 275 | damndest to deal with it. "numeric" governs whether we do any DNS at all, |
| 329 | and we also check o_verbose for what's appropriate work to do. */ | 276 | and we also check o_verbose for what's appropriate work to do. */ |
| 330 | HINF * | 277 | struct host_info * |
| 331 | gethostpoop(name, numeric) | 278 | gethostpoop(name, numeric) |
| 332 | char *name; | 279 | char *name; |
| 333 | USHORT numeric; | 280 | u_short numeric; |
| 334 | { | 281 | { |
| 335 | struct hostent *hostent; | 282 | struct hostent *hostent; |
| 336 | struct in_addr iaddr; | 283 | struct in_addr iaddr; |
| 337 | register HINF *poop = NULL; | 284 | register struct host_info *poop = NULL; |
| 338 | register int x; | 285 | register int x; |
| 339 | 286 | ||
| 340 | /* I really want to strangle the twit who dreamed up all these sockaddr and | 287 | /* I really want to strangle the twit who dreamed up all these sockaddr and |
| @@ -359,12 +306,11 @@ gethostpoop(name, numeric) | |||
| 359 | errno = 0; | 306 | errno = 0; |
| 360 | h_errno = 0; | 307 | h_errno = 0; |
| 361 | if (name) | 308 | if (name) |
| 362 | poop = (HINF *) Hmalloc(sizeof(HINF)); | 309 | poop = (struct host_info *) calloc(1, sizeof(struct host_info)); |
| 363 | if (!poop) | 310 | if (!poop) |
| 364 | bail("gethostpoop fuxored"); | 311 | bail("gethostpoop fuxored"); |
| 365 | strlcpy(poop->name, unknown, sizeof(poop->name)); /* preload it */ | 312 | strlcpy(poop->name, "(UNKNOWN)", sizeof(poop->name)); |
| 366 | if (inet_aton(name, &iaddr) == 0) { /* here's the great split: | 313 | if (inet_aton(name, &iaddr) == 0) { |
| 367 | * names... */ | ||
| 368 | 314 | ||
| 369 | if (numeric) | 315 | if (numeric) |
| 370 | bail("Can't parse %s as an IP address", name); | 316 | bail("Can't parse %s as an IP address", name); |
| @@ -372,21 +318,20 @@ gethostpoop(name, numeric) | |||
| 372 | if (!hostent) | 318 | if (!hostent) |
| 373 | /* failure to look up a name is fatal, since we can't do anything with it */ | 319 | /* failure to look up a name is fatal, since we can't do anything with it */ |
| 374 | bail("%s: forward host lookup failed: ", name); | 320 | bail("%s: forward host lookup failed: ", name); |
| 375 | strncpy(poop->name, hostent->h_name, MAXHOSTNAMELEN - 1); | 321 | strlcpy(poop->name, hostent->h_name, MAXHOSTNAMELEN); |
| 376 | poop->name[MAXHOSTNAMELEN - 1] = '\0'; | ||
| 377 | for (x = 0; hostent->h_addr_list[x] && (x < 8); x++) { | 322 | for (x = 0; hostent->h_addr_list[x] && (x < 8); x++) { |
| 378 | memcpy(&poop->iaddrs[x], hostent->h_addr_list[x], sizeof(IA)); | 323 | memcpy(&poop->iaddrs[x], hostent->h_addr_list[x], |
| 379 | strncpy(poop->addrs[x], inet_ntoa(poop->iaddrs[x]), | 324 | sizeof(struct in_addr)); |
| 380 | sizeof(poop->addrs[0]) - 1); | 325 | strlcpy(poop->addrs[x], inet_ntoa(poop->iaddrs[x]), |
| 381 | poop->addrs[x][sizeof(poop->addrs[0]) - 1] = '\0'; | 326 | sizeof(poop->addrs[0])); |
| 382 | } /* for x -> addrs, part A */ | 327 | } |
| 383 | if (!o_verbose) /* if we didn't want to see the */ | 328 | if (!o_verbose) /* if we didn't want to see the */ |
| 384 | return (poop); /* inverse stuff, we're done. */ | 329 | return (poop); /* inverse stuff, we're done. */ |
| 385 | /* do inverse lookups in separate loop based on our collected forward addrs, | 330 | /* do inverse lookups in separate loop based on our collected forward addrs, |
| 386 | since gethostby* tends to crap into the same buffer over and over */ | 331 | since gethostby* tends to crap into the same buffer over and over */ |
| 387 | for (x = 0; poop->iaddrs[x].s_addr && (x < 8); x++) { | 332 | for (x = 0; poop->iaddrs[x].s_addr && (x < 8); x++) { |
| 388 | hostent = gethostbyaddr((char *) &poop->iaddrs[x], | 333 | hostent = gethostbyaddr((char *) &poop->iaddrs[x], |
| 389 | sizeof(IA), AF_INET); | 334 | sizeof(struct in_addr), AF_INET); |
| 390 | if ((!hostent) || (!hostent->h_name)) | 335 | if ((!hostent) || (!hostent->h_name)) |
| 391 | holler("Warning: inverse host lookup failed for %s: ", | 336 | holler("Warning: inverse host lookup failed for %s: ", |
| 392 | poop->addrs[x]); | 337 | poop->addrs[x]); |
| @@ -395,20 +340,18 @@ gethostpoop(name, numeric) | |||
| 395 | } /* for x -> addrs, part B */ | 340 | } /* for x -> addrs, part B */ |
| 396 | 341 | ||
| 397 | } else { /* not INADDR_NONE: numeric addresses... */ | 342 | } else { /* not INADDR_NONE: numeric addresses... */ |
| 398 | memcpy(poop->iaddrs, &iaddr, sizeof(IA)); | 343 | memcpy(poop->iaddrs, &iaddr, sizeof(struct in_addr)); |
| 399 | strncpy(poop->addrs[0], inet_ntoa(iaddr), sizeof(poop->addrs) - 1); | 344 | strlcpy(poop->addrs[0], inet_ntoa(iaddr), sizeof(poop->addrs)); |
| 400 | poop->addrs[0][sizeof(poop->addrs) - 1] = '\0'; | ||
| 401 | if (numeric) /* if numeric-only, we're done */ | 345 | if (numeric) /* if numeric-only, we're done */ |
| 402 | return (poop); | 346 | return (poop); |
| 403 | if (!o_verbose) /* likewise if we don't want */ | 347 | if (!o_verbose) /* likewise if we don't want */ |
| 404 | return (poop); /* the full DNS hair */ | 348 | return (poop); /* the full DNS hair */ |
| 405 | hostent = gethostbyaddr((char *) &iaddr, sizeof(IA), AF_INET); | 349 | hostent = gethostbyaddr((char *) &iaddr, sizeof(struct in_addr), AF_INET); |
| 406 | /* numeric or not, failure to look up a PTR is *not* considered fatal */ | 350 | /* numeric or not, failure to look up a PTR is *not* considered fatal */ |
| 407 | if (!hostent) | 351 | if (!hostent) |
| 408 | holler("%s: inverse host lookup failed: ", name); | 352 | holler("%s: inverse host lookup failed: ", name); |
| 409 | else { | 353 | else { |
| 410 | strncpy(poop->name, hostent->h_name, MAXHOSTNAMELEN - 1); | 354 | strlcpy(poop->name, hostent->h_name, MAXHOSTNAMELEN); |
| 411 | poop->name[MAXHOSTNAMELEN - 1] = '\0'; | ||
| 412 | hostent = gethostbyname(poop->name); | 355 | hostent = gethostbyname(poop->name); |
| 413 | if ((!hostent) || (!hostent->h_addr_list[0])) | 356 | if ((!hostent) || (!hostent->h_addr_list[0])) |
| 414 | holler("Warning: forward host lookup failed for %s: ", | 357 | holler("Warning: forward host lookup failed for %s: ", |
| @@ -418,20 +361,20 @@ gethostpoop(name, numeric) | |||
| 418 | } /* if hostent */ | 361 | } /* if hostent */ |
| 419 | } /* INADDR_NONE Great Split */ | 362 | } /* INADDR_NONE Great Split */ |
| 420 | 363 | ||
| 421 | /* whatever-all went down previously, we should now have a host_poop struct | 364 | /* whatever-all went down previously, we should now have a host_info struct |
| 422 | with at least one IP address in it. */ | 365 | with at least one IP address in it. */ |
| 423 | h_errno = 0; | 366 | h_errno = 0; |
| 424 | return (poop); | 367 | return (poop); |
| 425 | } /* gethostpoop */ | 368 | } |
| 426 | 369 | ||
| 427 | /* getportpoop : | 370 | /* getportpoop : |
| 428 | Same general idea as gethostpoop -- look up a port in /etc/services, fill | 371 | Same general idea as gethostpoop -- look up a port in /etc/services, fill |
| 429 | in global port_poop, but return the actual port *number*. Pass ONE of: | 372 | in global port_info, but return the actual port *number*. Pass ONE of: |
| 430 | pstring to resolve stuff like "23" or "exec"; | 373 | pstring to resolve stuff like "23" or "exec"; |
| 431 | pnum to reverse-resolve something that's already a number. | 374 | pnum to reverse-resolve something that's already a number. |
| 432 | If o_nflag is on, fill in what we can but skip the getservby??? stuff. | 375 | If o_nflag is on, fill in what we can but skip the getservby??? stuff. |
| 433 | Might as well have consistent behavior here, and it *is* faster. */ | 376 | Might as well have consistent behavior here, and it *is* faster. */ |
| 434 | USHORT | 377 | u_short |
| 435 | getportpoop(pstring, pnum) | 378 | getportpoop(pstring, pnum) |
| 436 | char *pstring; | 379 | char *pstring; |
| 437 | unsigned int pnum; | 380 | unsigned int pnum; |
| @@ -439,9 +382,9 @@ getportpoop(pstring, pnum) | |||
| 439 | struct servent *servent; | 382 | struct servent *servent; |
| 440 | register int x; | 383 | register int x; |
| 441 | register int y; | 384 | register int y; |
| 442 | char *whichp = p_tcp; | 385 | char *whichp = "tcp"; |
| 443 | if (o_udpmode) | 386 | if (o_udpmode) |
| 444 | whichp = p_udp; | 387 | whichp = "udp"; |
| 445 | portpoop->name[0] = '?';/* fast preload */ | 388 | portpoop->name[0] = '?';/* fast preload */ |
| 446 | portpoop->name[1] = '\0'; | 389 | portpoop->name[1] = '\0'; |
| 447 | 390 | ||
| @@ -459,9 +402,9 @@ getportpoop(pstring, pnum) | |||
| 459 | y = ntohs(servent->s_port); | 402 | y = ntohs(servent->s_port); |
| 460 | if (x != y) /* "never happen" */ | 403 | if (x != y) /* "never happen" */ |
| 461 | holler("Warning: port-bynum mismatch, %d != %d", x, y); | 404 | holler("Warning: port-bynum mismatch, %d != %d", x, y); |
| 462 | strncpy(portpoop->name, servent->s_name, sizeof(portpoop->name) - 1); | 405 | strlcpy(portpoop->name, servent->s_name, |
| 463 | portpoop->name[sizeof(portpoop->name) - 1] = '\0'; | 406 | sizeof(portpoop->name)); |
| 464 | } /* if servent */ | 407 | } |
| 465 | goto gp_finish; | 408 | goto gp_finish; |
| 466 | } /* if pnum */ | 409 | } /* if pnum */ |
| 467 | /* case 2: resolve a string, but we still give preference to numbers | 410 | /* case 2: resolve a string, but we still give preference to numbers |
| @@ -480,8 +423,8 @@ getportpoop(pstring, pnum) | |||
| 480 | return (0); | 423 | return (0); |
| 481 | servent = getservbyname(pstring, whichp); | 424 | servent = getservbyname(pstring, whichp); |
| 482 | if (servent) { | 425 | if (servent) { |
| 483 | strncpy(portpoop->name, servent->s_name, sizeof(portpoop->name) - 1); | 426 | strlcpy(portpoop->name, servent->s_name, |
| 484 | portpoop->name[sizeof(portpoop->name) - 1] = '\0'; | 427 | sizeof(portpoop->name)); |
| 485 | x = ntohs(servent->s_port); | 428 | x = ntohs(servent->s_port); |
| 486 | goto gp_finish; | 429 | goto gp_finish; |
| 487 | } /* if servent */ | 430 | } /* if servent */ |
| @@ -504,9 +447,9 @@ gp_finish: | |||
| 504 | x containing our [host-order and therefore useful, dammit] port number */ | 447 | x containing our [host-order and therefore useful, dammit] port number */ |
| 505 | sprintf(portpoop->anum, "%d", x); /* always load any numeric | 448 | sprintf(portpoop->anum, "%d", x); /* always load any numeric |
| 506 | * specs! */ | 449 | * specs! */ |
| 507 | portpoop->num = (x & 0xffff); /* ushort, remember... */ | 450 | portpoop->num = (x & 0xffff); /* u_short, remember... */ |
| 508 | return (portpoop->num); | 451 | return (portpoop->num); |
| 509 | } /* getportpoop */ | 452 | } |
| 510 | 453 | ||
| 511 | /* nextport : | 454 | /* nextport : |
| 512 | Come up with the next port to try, be it random or whatever. "block" is | 455 | Come up with the next port to try, be it random or whatever. "block" is |
| @@ -514,8 +457,8 @@ gp_finish: | |||
| 514 | 0 ignore | 457 | 0 ignore |
| 515 | 1 to be tested | 458 | 1 to be tested |
| 516 | 2 tested [which is set as we find them here] | 459 | 2 tested [which is set as we find them here] |
| 517 | returns a USHORT random port, or 0 if all the t-b-t ones are used up. */ | 460 | returns a u_short random port, or 0 if all the t-b-t ones are used up. */ |
| 518 | USHORT | 461 | u_short |
| 519 | nextport(block) | 462 | nextport(block) |
| 520 | char *block; | 463 | char *block; |
| 521 | { | 464 | { |
| @@ -547,7 +490,7 @@ nextport(block) | |||
| 547 | return (y); /* at least one left */ | 490 | return (y); /* at least one left */ |
| 548 | 491 | ||
| 549 | return (0); /* no more left! */ | 492 | return (0); /* no more left! */ |
| 550 | } /* nextport */ | 493 | } |
| 551 | 494 | ||
| 552 | /* loadports : | 495 | /* loadports : |
| 553 | set "to be tested" indications in BLOCK, from LO to HI. Almost too small | 496 | set "to be tested" indications in BLOCK, from LO to HI. Almost too small |
| @@ -555,10 +498,10 @@ nextport(block) | |||
| 555 | void | 498 | void |
| 556 | loadports(block, lo, hi) | 499 | loadports(block, lo, hi) |
| 557 | char *block; | 500 | char *block; |
| 558 | USHORT lo; | 501 | u_short lo; |
| 559 | USHORT hi; | 502 | u_short hi; |
| 560 | { | 503 | { |
| 561 | USHORT x; | 504 | u_short x; |
| 562 | 505 | ||
| 563 | if (!block) | 506 | if (!block) |
| 564 | bail("loadports: no block?!"); | 507 | bail("loadports: no block?!"); |
| @@ -569,7 +512,8 @@ loadports(block, lo, hi) | |||
| 569 | block[x] = 1; | 512 | block[x] = 1; |
| 570 | x--; | 513 | x--; |
| 571 | } | 514 | } |
| 572 | } /* loadports */ | 515 | } |
| 516 | |||
| 573 | #ifdef GAPING_SECURITY_HOLE | 517 | #ifdef GAPING_SECURITY_HOLE |
| 574 | char *pr00gie = NULL; /* global ptr to -e arg */ | 518 | char *pr00gie = NULL; /* global ptr to -e arg */ |
| 575 | 519 | ||
| @@ -596,7 +540,7 @@ doexec(fd) | |||
| 596 | Debug(("gonna exec %s as %s...", pr00gie, p)) | 540 | Debug(("gonna exec %s as %s...", pr00gie, p)) |
| 597 | execl(pr00gie, p, NULL); | 541 | execl(pr00gie, p, NULL); |
| 598 | bail("exec %s failed", pr00gie); /* this gets sent out. Hmm... */ | 542 | bail("exec %s failed", pr00gie); /* this gets sent out. Hmm... */ |
| 599 | } /* doexec */ | 543 | } |
| 600 | #endif /* GAPING_SECURITY_HOLE */ | 544 | #endif /* GAPING_SECURITY_HOLE */ |
| 601 | 545 | ||
| 602 | /* doconnect : | 546 | /* doconnect : |
| @@ -608,10 +552,10 @@ doexec(fd) | |||
| 608 | Examines various global o_blah flags to figure out what-all to do. */ | 552 | Examines various global o_blah flags to figure out what-all to do. */ |
| 609 | int | 553 | int |
| 610 | doconnect(rad, rp, lad, lp) | 554 | doconnect(rad, rp, lad, lp) |
| 611 | IA *rad; | 555 | struct in_addr *rad; |
| 612 | USHORT rp; | 556 | u_short rp; |
| 613 | IA *lad; | 557 | struct in_addr *lad; |
| 614 | USHORT lp; | 558 | u_short lp; |
| 615 | { | 559 | { |
| 616 | register int nnetfd; | 560 | register int nnetfd; |
| 617 | register int rr; | 561 | register int rr; |
| @@ -655,7 +599,7 @@ newskt: | |||
| 655 | 599 | ||
| 656 | /* if lad/lp, do appropriate binding */ | 600 | /* if lad/lp, do appropriate binding */ |
| 657 | if (lad) | 601 | if (lad) |
| 658 | memcpy(&lclend->sin_addr.s_addr, lad, sizeof(IA)); | 602 | memcpy(&lclend->sin_addr.s_addr, lad, sizeof(struct in_addr)); |
| 659 | if (lp) | 603 | if (lp) |
| 660 | lclend->sin_port = htons(lp); | 604 | lclend->sin_port = htons(lp); |
| 661 | rr = 0; | 605 | rr = 0; |
| @@ -663,7 +607,8 @@ newskt: | |||
| 663 | x = (int) lp; | 607 | x = (int) lp; |
| 664 | /* try a few times for the local bind, a la ftp-data-port... */ | 608 | /* try a few times for the local bind, a la ftp-data-port... */ |
| 665 | for (y = 4; y > 0; y--) { | 609 | for (y = 4; y > 0; y--) { |
| 666 | rr = bind(nnetfd, (SA *) lclend, sizeof(SA)); | 610 | rr = bind(nnetfd, (struct sockaddr *) lclend, |
| 611 | sizeof(struct sockaddr_in)); | ||
| 667 | if (rr == 0) | 612 | if (rr == 0) |
| 668 | break; | 613 | break; |
| 669 | if (errno != EADDRINUSE) | 614 | if (errno != EADDRINUSE) |
| @@ -682,7 +627,7 @@ newskt: | |||
| 682 | if (o_listen) | 627 | if (o_listen) |
| 683 | return (nnetfd);/* thanks, that's all for today */ | 628 | return (nnetfd);/* thanks, that's all for today */ |
| 684 | 629 | ||
| 685 | memcpy(&remend->sin_addr.s_addr, rad, sizeof(IA)); | 630 | memcpy(&remend->sin_addr.s_addr, rad, sizeof(struct in_addr)); |
| 686 | remend->sin_port = htons(rp); | 631 | remend->sin_port = htons(rp); |
| 687 | 632 | ||
| 688 | /* rough format of LSRR option and explanation of weirdness. | 633 | /* rough format of LSRR option and explanation of weirdness. |
| @@ -727,26 +672,26 @@ Linux is also still a loss at 1.3.x it looks like; the lsrr code is { }... | |||
| 727 | #ifdef IP_OPTIONS | 672 | #ifdef IP_OPTIONS |
| 728 | if (!optbuf) { /* and don't already *have* a srcrt set */ | 673 | if (!optbuf) { /* and don't already *have* a srcrt set */ |
| 729 | char *opp; /* then do all this setup hair */ | 674 | char *opp; /* then do all this setup hair */ |
| 730 | optbuf = Hmalloc(48); | 675 | optbuf = calloc(1, 48); |
| 731 | opp = optbuf; | 676 | opp = optbuf; |
| 732 | *opp++ = IPOPT_LSRR; /* option */ | 677 | *opp++ = IPOPT_LSRR; /* option */ |
| 733 | *opp++ = (char) | 678 | *opp++ = (char) |
| 734 | (((gatesidx + 1) * sizeof(IA)) + 3) & 0xff; /* length */ | 679 | (((gatesidx + 1) * sizeof(struct in_addr)) + 3) & 0xff; /* length */ |
| 735 | *opp++ = gatesptr; /* pointer */ | 680 | *opp++ = gatesptr; /* pointer */ |
| 736 | /* opp now points at first hop addr -- insert the intermediate gateways */ | 681 | /* opp now points at first hop addr -- insert the intermediate gateways */ |
| 737 | for (x = 0; x < gatesidx; x++) { | 682 | for (x = 0; x < gatesidx; x++) { |
| 738 | memcpy(opp, gates[x]->iaddrs, sizeof(IA)); | 683 | memcpy(opp, gates[x]->iaddrs, sizeof(struct in_addr)); |
| 739 | opp += sizeof(IA); | 684 | opp += sizeof(struct in_addr); |
| 740 | } | 685 | } |
| 741 | /* and tack the final destination on the end [needed!] */ | 686 | /* and tack the final destination on the end [needed!] */ |
| 742 | memcpy(opp, rad, sizeof(IA)); | 687 | memcpy(opp, rad, sizeof(struct in_addr)); |
| 743 | opp += sizeof(IA); | 688 | opp += sizeof(struct in_addr); |
| 744 | *opp = IPOPT_NOP; /* alignment filler */ | 689 | *opp = IPOPT_NOP; /* alignment filler */ |
| 745 | } /* if empty optbuf */ | 690 | } /* if empty optbuf */ |
| 746 | /* calculate length of whole option mess, which is (3 + [hops] | 691 | /* calculate length of whole option mess, which is (3 + [hops] |
| 747 | * + [final] + 1), and apply it [have to do this every time | 692 | * + [final] + 1), and apply it [have to do this every time |
| 748 | * through, of course] */ | 693 | * through, of course] */ |
| 749 | x = ((gatesidx + 1) * sizeof(IA)) + 4; | 694 | x = ((gatesidx + 1) * sizeof(struct in_addr)) + 4; |
| 750 | rr = setsockopt(nnetfd, IPPROTO_IP, IP_OPTIONS, optbuf, x); | 695 | rr = setsockopt(nnetfd, IPPROTO_IP, IP_OPTIONS, optbuf, x); |
| 751 | if (rr == -1) | 696 | if (rr == -1) |
| 752 | bail("srcrt setsockopt fuxored"); | 697 | bail("srcrt setsockopt fuxored"); |
| @@ -757,7 +702,7 @@ Linux is also still a loss at 1.3.x it looks like; the lsrr code is { }... | |||
| 757 | /* wrap connect inside a timer, and hit it */ | 702 | /* wrap connect inside a timer, and hit it */ |
| 758 | arm(1, o_wait); | 703 | arm(1, o_wait); |
| 759 | if (setjmp(jbuf) == 0) { | 704 | if (setjmp(jbuf) == 0) { |
| 760 | rr = connect(nnetfd, (SA *) remend, sizeof(SA)); | 705 | rr = connect(nnetfd, (struct sockaddr *) remend, sizeof(struct sockaddr)); |
| 761 | } else { /* setjmp: connect failed... */ | 706 | } else { /* setjmp: connect failed... */ |
| 762 | rr = -1; | 707 | rr = -1; |
| 763 | errno = ETIMEDOUT; /* fake it */ | 708 | errno = ETIMEDOUT; /* fake it */ |
| @@ -767,7 +712,7 @@ Linux is also still a loss at 1.3.x it looks like; the lsrr code is { }... | |||
| 767 | return (nnetfd); | 712 | return (nnetfd); |
| 768 | close(nnetfd); /* clean up junked socket FD!! */ | 713 | close(nnetfd); /* clean up junked socket FD!! */ |
| 769 | return (-1); | 714 | return (-1); |
| 770 | } /* doconnect */ | 715 | } |
| 771 | 716 | ||
| 772 | /* dolisten : | 717 | /* dolisten : |
| 773 | just like doconnect, and in fact calls a hunk of doconnect, but listens for | 718 | just like doconnect, and in fact calls a hunk of doconnect, but listens for |
| @@ -776,17 +721,17 @@ Linux is also still a loss at 1.3.x it looks like; the lsrr code is { }... | |||
| 776 | in conjunction with local-address binding should limit things nicely... */ | 721 | in conjunction with local-address binding should limit things nicely... */ |
| 777 | int | 722 | int |
| 778 | dolisten(rad, rp, lad, lp) | 723 | dolisten(rad, rp, lad, lp) |
| 779 | IA *rad; | 724 | struct in_addr *rad; |
| 780 | USHORT rp; | 725 | u_short rp; |
| 781 | IA *lad; | 726 | struct in_addr *lad; |
| 782 | USHORT lp; | 727 | u_short lp; |
| 783 | { | 728 | { |
| 784 | register int nnetfd; | 729 | register int nnetfd; |
| 785 | register int rr; | 730 | register int rr; |
| 786 | HINF *whozis = NULL; | 731 | struct host_info *whozis = NULL; |
| 787 | int x; | 732 | int x; |
| 788 | char *cp; | 733 | char *cp; |
| 789 | USHORT z; | 734 | u_short z; |
| 790 | errno = 0; | 735 | errno = 0; |
| 791 | 736 | ||
| 792 | /* Pass everything off to doconnect, who in o_listen mode just gets a socket */ | 737 | /* Pass everything off to doconnect, who in o_listen mode just gets a socket */ |
| @@ -808,12 +753,12 @@ dolisten(rad, rp, lad, lp) | |||
| 808 | /* I can't believe I have to do all this to get my own goddamn bound address | 753 | /* I can't believe I have to do all this to get my own goddamn bound address |
| 809 | and port number. It should just get filled in during bind() or something. | 754 | and port number. It should just get filled in during bind() or something. |
| 810 | All this is only useful if we didn't say -p for listening, since if we | 755 | All this is only useful if we didn't say -p for listening, since if we |
| 811 | said -p we *know* what port we're listening on. At any rate we won't bother | 756 | struct sockaddr_ind -p we *know* what port we're listening on. At any rate we won't bother |
| 812 | with it all unless we wanted to see it, although listening quietly on a | 757 | with it all unless we wanted to see it, although listening quietly on a |
| 813 | random unknown port is probably not very useful without "netstat". */ | 758 | random unknown port is probably not very useful without "netstat". */ |
| 814 | if (o_verbose) { | 759 | if (o_verbose) { |
| 815 | x = sizeof(SA); /* how 'bout getsockNUM instead, pinheads?! */ | 760 | x = sizeof(struct sockaddr); /* how 'bout getsockNUM instead, pinheads?! */ |
| 816 | rr = getsockname(nnetfd, (SA *) lclend, &x); | 761 | rr = getsockname(nnetfd, (struct sockaddr *) lclend, &x); |
| 817 | if (rr < 0) | 762 | if (rr < 0) |
| 818 | holler("local getsockname failed"); | 763 | holler("local getsockname failed"); |
| 819 | strcpy(bigbuf_net, "listening on ["); /* buffer reuse... */ | 764 | strcpy(bigbuf_net, "listening on ["); /* buffer reuse... */ |
| @@ -832,12 +777,12 @@ dolisten(rad, rp, lad, lp) | |||
| 832 | * straight read/write actually does work after all. Yow. YMMV on | 777 | * straight read/write actually does work after all. Yow. YMMV on |
| 833 | * strange platforms! */ | 778 | * strange platforms! */ |
| 834 | if (o_udpmode) { | 779 | if (o_udpmode) { |
| 835 | x = sizeof(SA); /* retval for recvfrom */ | 780 | x = sizeof(struct sockaddr); /* retval for recvfrom */ |
| 836 | arm(2, o_wait); /* might as well timeout this, too */ | 781 | arm(2, o_wait); /* might as well timeout this, too */ |
| 837 | if (setjmp(jbuf) == 0) { /* do timeout for initial | 782 | if (setjmp(jbuf) == 0) { /* do timeout for initial |
| 838 | * connect */ | 783 | * connect */ |
| 839 | rr = recvfrom /* and here we block... */ | 784 | rr = recvfrom /* and here we block... */ |
| 840 | (nnetfd, bigbuf_net, BIGSIZ, MSG_PEEK, (SA *) remend, &x); | 785 | (nnetfd, bigbuf_net, BIGSIZ, MSG_PEEK, (struct sockaddr *) remend, &x); |
| 841 | Debug(("dolisten/recvfrom ding, rr = %d, netbuf %s ", rr, bigbuf_net)) | 786 | Debug(("dolisten/recvfrom ding, rr = %d, netbuf %s ", rr, bigbuf_net)) |
| 842 | } else | 787 | } else |
| 843 | goto dol_tmo; /* timeout */ | 788 | goto dol_tmo; /* timeout */ |
| @@ -853,14 +798,14 @@ dolisten(rad, rp, lad, lp) | |||
| 853 | different port on the other end won't show up and will cause ICMP errors. | 798 | different port on the other end won't show up and will cause ICMP errors. |
| 854 | I guess that's what they meant by "connect". | 799 | I guess that's what they meant by "connect". |
| 855 | Let's try to remember what the "U" is *really* for, eh? */ | 800 | Let's try to remember what the "U" is *really* for, eh? */ |
| 856 | rr = connect(nnetfd, (SA *) remend, sizeof(SA)); | 801 | rr = connect(nnetfd, (struct sockaddr *) remend, sizeof(struct sockaddr)); |
| 857 | goto whoisit; | 802 | goto whoisit; |
| 858 | } /* o_udpmode */ | 803 | } /* o_udpmode */ |
| 859 | /* fall here for TCP */ | 804 | /* fall here for TCP */ |
| 860 | x = sizeof(SA); /* retval for accept */ | 805 | x = sizeof(struct sockaddr); /* retval for accept */ |
| 861 | arm(2, o_wait); /* wrap this in a timer, too; 0 = forever */ | 806 | arm(2, o_wait); /* wrap this in a timer, too; 0 = forever */ |
| 862 | if (setjmp(jbuf) == 0) { | 807 | if (setjmp(jbuf) == 0) { |
| 863 | rr = accept(nnetfd, (SA *) remend, &x); | 808 | rr = accept(nnetfd, (struct sockaddr *) remend, &x); |
| 864 | } else | 809 | } else |
| 865 | goto dol_tmo; /* timeout */ | 810 | goto dol_tmo; /* timeout */ |
| 866 | arm(0, 0); | 811 | arm(0, 0); |
| @@ -879,7 +824,7 @@ whoisit: | |||
| 879 | #ifdef IP_OPTIONS | 824 | #ifdef IP_OPTIONS |
| 880 | if (!o_verbose) /* if we wont see it, we dont care */ | 825 | if (!o_verbose) /* if we wont see it, we dont care */ |
| 881 | goto dol_noop; | 826 | goto dol_noop; |
| 882 | optbuf = Hmalloc(40); | 827 | optbuf = calloc(1, 40); |
| 883 | x = 40; | 828 | x = 40; |
| 884 | rr = getsockopt(nnetfd, IPPROTO_IP, IP_OPTIONS, optbuf, &x); | 829 | rr = getsockopt(nnetfd, IPPROTO_IP, IP_OPTIONS, optbuf, &x); |
| 885 | if (rr < 0) | 830 | if (rr < 0) |
| @@ -910,8 +855,8 @@ dol_noop: | |||
| 910 | "virtual web site" hack. */ | 855 | "virtual web site" hack. */ |
| 911 | memset(bigbuf_net, 0, 64); | 856 | memset(bigbuf_net, 0, 64); |
| 912 | cp = &bigbuf_net[32]; | 857 | cp = &bigbuf_net[32]; |
| 913 | x = sizeof(SA); | 858 | x = sizeof(struct sockaddr); |
| 914 | rr = getsockname(nnetfd, (SA *) lclend, &x); | 859 | rr = getsockname(nnetfd, (struct sockaddr *) lclend, &x); |
| 915 | if (rr < 0) | 860 | if (rr < 0) |
| 916 | holler("post-rcv getsockname failed"); | 861 | holler("post-rcv getsockname failed"); |
| 917 | strcpy(cp, inet_ntoa(lclend->sin_addr)); | 862 | strcpy(cp, inet_ntoa(lclend->sin_addr)); |
| @@ -932,7 +877,7 @@ dol_noop: | |||
| 932 | x = 0; /* use as a flag... */ | 877 | x = 0; /* use as a flag... */ |
| 933 | if (rad) /* xxx: fix to go down the *list* if we have | 878 | if (rad) /* xxx: fix to go down the *list* if we have |
| 934 | * one? */ | 879 | * one? */ |
| 935 | if (memcmp(rad, whozis->iaddrs, sizeof(SA))) | 880 | if (memcmp(rad, whozis->iaddrs, sizeof(struct sockaddr))) |
| 936 | x = 1; | 881 | x = 1; |
| 937 | if (rp) | 882 | if (rp) |
| 938 | if (z != rp) | 883 | if (z != rp) |
| @@ -949,7 +894,7 @@ dol_tmo: | |||
| 949 | dol_err: | 894 | dol_err: |
| 950 | close(nnetfd); | 895 | close(nnetfd); |
| 951 | return (-1); | 896 | return (-1); |
| 952 | } /* dolisten */ | 897 | } |
| 953 | 898 | ||
| 954 | /* udptest : | 899 | /* udptest : |
| 955 | fire a couple of packets at a UDP target port, just to see if it's really | 900 | fire a couple of packets at a UDP target port, just to see if it's really |
| @@ -963,7 +908,7 @@ dol_err: | |||
| 963 | Return either the original fd, or clean up and return -1. */ | 908 | Return either the original fd, or clean up and return -1. */ |
| 964 | udptest(fd, where) | 909 | udptest(fd, where) |
| 965 | int fd; | 910 | int fd; |
| 966 | IA *where; | 911 | struct in_addr *where; |
| 967 | { | 912 | { |
| 968 | register int rr; | 913 | register int rr; |
| 969 | 914 | ||
| @@ -992,7 +937,8 @@ udptest(fd, where) | |||
| 992 | return (fd); | 937 | return (fd); |
| 993 | close(fd); /* use it or lose it! */ | 938 | close(fd); /* use it or lose it! */ |
| 994 | return (-1); | 939 | return (-1); |
| 995 | } /* udptest */ | 940 | } |
| 941 | |||
| 996 | /* oprint : | 942 | /* oprint : |
| 997 | Hexdump bytes shoveled either way to a running logfile, in the format: | 943 | Hexdump bytes shoveled either way to a running logfile, in the format: |
| 998 | D offset - - - - --- 16 bytes --- - - - - # .... ascii ..... | 944 | D offset - - - - --- 16 bytes --- - - - - # .... ascii ..... |
| @@ -1084,9 +1030,10 @@ oprint(which, buf, n) | |||
| 1084 | if (x < 0) | 1030 | if (x < 0) |
| 1085 | bail("ofd write err"); | 1031 | bail("ofd write err"); |
| 1086 | } /* while bc */ | 1032 | } /* while bc */ |
| 1087 | } /* oprint */ | 1033 | } |
| 1034 | |||
| 1088 | #ifdef TELNET | 1035 | #ifdef TELNET |
| 1089 | USHORT o_tn = 0; /* global -t option */ | 1036 | u_short o_tn = 0; /* global -t option */ |
| 1090 | 1037 | ||
| 1091 | /* atelnet : | 1038 | /* atelnet : |
| 1092 | Answer anything that looks like telnet negotiation with don't/won't. | 1039 | Answer anything that looks like telnet negotiation with don't/won't. |
| @@ -1129,7 +1076,8 @@ notiac: | |||
| 1129 | p++; | 1076 | p++; |
| 1130 | x--; | 1077 | x--; |
| 1131 | } /* while x */ | 1078 | } /* while x */ |
| 1132 | } /* atelnet */ | 1079 | } |
| 1080 | |||
| 1133 | #endif /* TELNET */ | 1081 | #endif /* TELNET */ |
| 1134 | 1082 | ||
| 1135 | /* readwrite : | 1083 | /* readwrite : |
| @@ -1144,17 +1092,17 @@ readwrite(fd) | |||
| 1144 | register char *np; /* net-in buf ptr */ | 1092 | register char *np; /* net-in buf ptr */ |
| 1145 | unsigned int rzleft; | 1093 | unsigned int rzleft; |
| 1146 | unsigned int rnleft; | 1094 | unsigned int rnleft; |
| 1147 | USHORT netretry; /* net-read retry counter */ | 1095 | u_short netretry; /* net-read retry counter */ |
| 1148 | USHORT wretry; /* net-write sanity counter */ | 1096 | u_short wretry; /* net-write sanity counter */ |
| 1149 | USHORT wfirst; /* one-shot flag to skip first net read */ | 1097 | u_short wfirst; /* one-shot flag to skip first net read */ |
| 1150 | 1098 | ||
| 1151 | /* if you don't have all this FD_* macro hair in sys/types.h, you'll have to | 1099 | /* if you don't have all this FD_* macro hair in sys/types.h, you'll have to |
| 1152 | either find it or do your own bit-bashing: *ding1 |= (1 << fd), etc... */ | 1100 | either find it or do your own bit-bashing: *fds1 |= (1 << fd), etc... */ |
| 1153 | if (fd > FD_SETSIZE) { | 1101 | if (fd > FD_SETSIZE) { |
| 1154 | holler("Preposterous fd value %d", fd); | 1102 | holler("Preposterous fd value %d", fd); |
| 1155 | return (1); | 1103 | return (1); |
| 1156 | } | 1104 | } |
| 1157 | FD_SET(fd, ding1); /* global: the net is open */ | 1105 | FD_SET(fd, &fds1); /* global: the net is open */ |
| 1158 | netretry = 2; | 1106 | netretry = 2; |
| 1159 | wfirst = 0; | 1107 | wfirst = 0; |
| 1160 | rzleft = rnleft = 0; | 1108 | rzleft = rnleft = 0; |
| @@ -1166,7 +1114,7 @@ readwrite(fd) | |||
| 1166 | insaved = 0; /* buffer left over from argv | 1114 | insaved = 0; /* buffer left over from argv |
| 1167 | * construction, */ | 1115 | * construction, */ |
| 1168 | else { | 1116 | else { |
| 1169 | FD_CLR(0, ding1); /* OR we've already got our | 1117 | FD_CLR(0, &fds1); /* OR we've already got our |
| 1170 | * repeat chunk, */ | 1118 | * repeat chunk, */ |
| 1171 | close(0); /* so we won't need any more stdin */ | 1119 | close(0); /* so we won't need any more stdin */ |
| 1172 | } /* Single */ | 1120 | } /* Single */ |
| @@ -1176,18 +1124,15 @@ readwrite(fd) | |||
| 1176 | errno = 0; /* clear from sleep, close, whatever */ | 1124 | errno = 0; /* clear from sleep, close, whatever */ |
| 1177 | 1125 | ||
| 1178 | /* and now the big ol' select shoveling loop ... */ | 1126 | /* and now the big ol' select shoveling loop ... */ |
| 1179 | while (FD_ISSET(fd, ding1)) { /* i.e. till the *net* closes! */ | 1127 | while (FD_ISSET(fd, &fds1)) { /* i.e. till the *net* closes! */ |
| 1180 | wretry = 8200; /* more than we'll ever hafta write */ | 1128 | wretry = 8200; /* more than we'll ever hafta write */ |
| 1181 | if (wfirst) { /* any saved stdin buffer? */ | 1129 | if (wfirst) { /* any saved stdin buffer? */ |
| 1182 | wfirst = 0; /* clear flag for the duration */ | 1130 | wfirst = 0; /* clear flag for the duration */ |
| 1183 | goto shovel; /* and go handle it first */ | 1131 | goto shovel; /* and go handle it first */ |
| 1184 | } | 1132 | } |
| 1185 | *ding2 = *ding1;/* FD_COPY ain't portable... */ | 1133 | fds2 = fds1; |
| 1186 | /* some systems, notably linux, crap into their select timers on return, so | 1134 | memcpy(&timer2, &timer1, sizeof(struct timeval)); |
| 1187 | we create a expendable copy and give *that* to select. *Fuck* me ... */ | 1135 | rr = select(getdtablesize(), &fds2, 0, 0, &timer2); |
| 1188 | if (timer1) | ||
| 1189 | memcpy(timer2, timer1, sizeof(struct timeval)); | ||
| 1190 | rr = select(16, ding2, 0, 0, timer2); /* here it is, kiddies */ | ||
| 1191 | if (rr < 0) { | 1136 | if (rr < 0) { |
| 1192 | if (errno != EINTR) { /* might have gotten ^Zed, etc | 1137 | if (errno != EINTR) { /* might have gotten ^Zed, etc |
| 1193 | * ? */ | 1138 | * ? */ |
| @@ -1200,7 +1145,7 @@ readwrite(fd) | |||
| 1200 | * heard anything from the net during that time, assume it's | 1145 | * heard anything from the net during that time, assume it's |
| 1201 | * dead and close it too. */ | 1146 | * dead and close it too. */ |
| 1202 | if (rr == 0) { | 1147 | if (rr == 0) { |
| 1203 | if (!FD_ISSET(0, ding1)) | 1148 | if (!FD_ISSET(0, &fds1)) |
| 1204 | netretry--; /* we actually try a coupla | 1149 | netretry--; /* we actually try a coupla |
| 1205 | * times. */ | 1150 | * times. */ |
| 1206 | if (!netretry) { | 1151 | if (!netretry) { |
| @@ -1216,10 +1161,10 @@ readwrite(fd) | |||
| 1216 | * found bothered. */ | 1161 | * found bothered. */ |
| 1217 | /* Ding!! Something arrived, go check all the incoming | 1162 | /* Ding!! Something arrived, go check all the incoming |
| 1218 | * hoppers, net first */ | 1163 | * hoppers, net first */ |
| 1219 | if (FD_ISSET(fd, ding2)) { /* net: ding! */ | 1164 | if (FD_ISSET(fd, &fds2)) { /* net: ding! */ |
| 1220 | rr = read(fd, bigbuf_net, BIGSIZ); | 1165 | rr = read(fd, bigbuf_net, BIGSIZ); |
| 1221 | if (rr <= 0) { | 1166 | if (rr <= 0) { |
| 1222 | FD_CLR(fd, ding1); /* net closed, we'll | 1167 | FD_CLR(fd, &fds1); /* net closed, we'll |
| 1223 | * finish up... */ | 1168 | * finish up... */ |
| 1224 | rzleft = 0; /* can't write anymore: broken | 1169 | rzleft = 0; /* can't write anymore: broken |
| 1225 | * pipe */ | 1170 | * pipe */ |
| @@ -1240,12 +1185,12 @@ readwrite(fd) | |||
| 1240 | goto shovel; | 1185 | goto shovel; |
| 1241 | 1186 | ||
| 1242 | /* okay, suck more stdin */ | 1187 | /* okay, suck more stdin */ |
| 1243 | if (FD_ISSET(0, ding2)) { /* stdin: ding! */ | 1188 | if (FD_ISSET(0, &fds2)) { /* stdin: ding! */ |
| 1244 | rr = read(0, bigbuf_in, BIGSIZ); | 1189 | rr = read(0, bigbuf_in, BIGSIZ); |
| 1245 | /* Considered making reads here smaller for UDP mode, but 8192-byte | 1190 | /* Considered making reads here smaller for UDP mode, but 8192-byte |
| 1246 | mobygrams are kinda fun and exercise the reassembler. */ | 1191 | mobygrams are kinda fun and exercise the reassembler. */ |
| 1247 | if (rr <= 0) { /* at end, or fukt, or ... */ | 1192 | if (rr <= 0) { /* at end, or fukt, or ... */ |
| 1248 | FD_CLR(0, ding1); /* disable and close | 1193 | FD_CLR(0, &fds1); /* disable and close |
| 1249 | * stdin */ | 1194 | * stdin */ |
| 1250 | close(0); | 1195 | close(0); |
| 1251 | } else { | 1196 | } else { |
| @@ -1255,7 +1200,7 @@ readwrite(fd) | |||
| 1255 | open TCP port or every UDP attempt, so save its size and clean up stdin */ | 1200 | open TCP port or every UDP attempt, so save its size and clean up stdin */ |
| 1256 | if (!Single) { /* we might be scanning... */ | 1201 | if (!Single) { /* we might be scanning... */ |
| 1257 | insaved = rr; /* save len */ | 1202 | insaved = rr; /* save len */ |
| 1258 | FD_CLR(0, ding1); /* disable further junk | 1203 | FD_CLR(0, &fds1); /* disable further junk |
| 1259 | * from stdin */ | 1204 | * from stdin */ |
| 1260 | close(0); /* really, I mean it */ | 1205 | close(0); /* really, I mean it */ |
| 1261 | } /* Single */ | 1206 | } /* Single */ |
| @@ -1314,7 +1259,7 @@ shovel: | |||
| 1314 | wretry--; /* none left, and get another load */ | 1259 | wretry--; /* none left, and get another load */ |
| 1315 | goto shovel; | 1260 | goto shovel; |
| 1316 | } | 1261 | } |
| 1317 | } /* while ding1:netfd is open */ | 1262 | } /* while fds1:netfd is open */ |
| 1318 | 1263 | ||
| 1319 | /* XXX: maybe want a more graceful shutdown() here, or screw around with | 1264 | /* XXX: maybe want a more graceful shutdown() here, or screw around with |
| 1320 | linger times?? I suspect that I don't need to since I'm always doing | 1265 | linger times?? I suspect that I don't need to since I'm always doing |
| @@ -1323,7 +1268,7 @@ shovel: | |||
| 1323 | not like my test network is particularly busy... */ | 1268 | not like my test network is particularly busy... */ |
| 1324 | close(fd); | 1269 | close(fd); |
| 1325 | return (0); | 1270 | return (0); |
| 1326 | } /* readwrite */ | 1271 | } |
| 1327 | 1272 | ||
| 1328 | /* main : | 1273 | /* main : |
| 1329 | now we pull it all together... */ | 1274 | now we pull it all together... */ |
| @@ -1337,16 +1282,16 @@ main(argc, argv) | |||
| 1337 | #endif | 1282 | #endif |
| 1338 | register int x; | 1283 | register int x; |
| 1339 | register char *cp; | 1284 | register char *cp; |
| 1340 | HINF *gp; | 1285 | struct host_info *gp; |
| 1341 | HINF *whereto = NULL; | 1286 | struct host_info *whereto = NULL; |
| 1342 | HINF *wherefrom = NULL; | 1287 | struct host_info *wherefrom = NULL; |
| 1343 | IA *ouraddr = NULL; | 1288 | struct in_addr *ouraddr = NULL; |
| 1344 | IA *themaddr = NULL; | 1289 | struct in_addr *themaddr = NULL; |
| 1345 | USHORT o_lport = 0; | 1290 | u_short o_lport = 0; |
| 1346 | USHORT ourport = 0; | 1291 | u_short ourport = 0; |
| 1347 | USHORT loport = 0; /* for scanning stuff */ | 1292 | u_short loport = 0; /* for scanning stuff */ |
| 1348 | USHORT hiport = 0; | 1293 | u_short hiport = 0; |
| 1349 | USHORT curport = 0; | 1294 | u_short curport = 0; |
| 1350 | char *randports = NULL; | 1295 | char *randports = NULL; |
| 1351 | 1296 | ||
| 1352 | #ifdef HAVE_BIND | 1297 | #ifdef HAVE_BIND |
| @@ -1355,13 +1300,11 @@ main(argc, argv) | |||
| 1355 | #endif | 1300 | #endif |
| 1356 | /* I was in this barbershop quartet in Skokie IL ... */ | 1301 | /* I was in this barbershop quartet in Skokie IL ... */ |
| 1357 | /* round up the usual suspects, i.e. malloc up all the stuff we need */ | 1302 | /* round up the usual suspects, i.e. malloc up all the stuff we need */ |
| 1358 | lclend = (SAI *) Hmalloc(sizeof(SA)); | 1303 | lclend = (struct sockaddr_in *) calloc(1, sizeof(struct sockaddr)); |
| 1359 | remend = (SAI *) Hmalloc(sizeof(SA)); | 1304 | remend = (struct sockaddr_in *) calloc(1, sizeof(struct sockaddr)); |
| 1360 | bigbuf_in = Hmalloc(BIGSIZ); | 1305 | bigbuf_in = calloc(1, BIGSIZ); |
| 1361 | bigbuf_net = Hmalloc(BIGSIZ); | 1306 | bigbuf_net = calloc(1, BIGSIZ); |
| 1362 | ding1 = (fd_set *) Hmalloc(sizeof(fd_set)); | 1307 | portpoop = (struct port_info *) calloc(1, sizeof(struct port_info)); |
| 1363 | ding2 = (fd_set *) Hmalloc(sizeof(fd_set)); | ||
| 1364 | portpoop = (PINF *) Hmalloc(sizeof(PINF)); | ||
| 1365 | 1308 | ||
| 1366 | errno = 0; | 1309 | errno = 0; |
| 1367 | gatesptr = 4; | 1310 | gatesptr = 4; |
| @@ -1383,9 +1326,9 @@ main(argc, argv) | |||
| 1383 | anything left over to readwrite(). */ | 1326 | anything left over to readwrite(). */ |
| 1384 | if (argc == 1) { | 1327 | if (argc == 1) { |
| 1385 | cp = argv[0]; | 1328 | cp = argv[0]; |
| 1386 | argv = (char **) Hmalloc(128 * sizeof(char *)); /* XXX: 128? */ | 1329 | argv = (char **) calloc(1, 128 * sizeof(char *)); /* XXX: 128? */ |
| 1387 | argv[0] = cp; /* leave old prog name intact */ | 1330 | argv[0] = cp; /* leave old prog name intact */ |
| 1388 | cp = Hmalloc(BIGSIZ); | 1331 | cp = calloc(1, BIGSIZ); |
| 1389 | argv[1] = cp; /* head of new arg block */ | 1332 | argv[1] = cp; /* head of new arg block */ |
| 1390 | fprintf(stderr, "Cmd line: "); | 1333 | fprintf(stderr, "Cmd line: "); |
| 1391 | fflush(stderr); /* I dont care if it's unbuffered or not! */ | 1334 | fflush(stderr); /* I dont care if it's unbuffered or not! */ |
| @@ -1450,7 +1393,7 @@ main(argc, argv) | |||
| 1450 | if (gatesidx > 8) | 1393 | if (gatesidx > 8) |
| 1451 | bail("too many -g hops"); | 1394 | bail("too many -g hops"); |
| 1452 | if (gates == NULL) /* eat this, Billy-boy */ | 1395 | if (gates == NULL) /* eat this, Billy-boy */ |
| 1453 | gates = (HINF **) Hmalloc(sizeof(HINF *) * 10); | 1396 | gates = (struct host_info **) calloc(1, sizeof(struct host_info *) * 10); |
| 1454 | gp = gethostpoop(optarg, o_nflag); | 1397 | gp = gethostpoop(optarg, o_nflag); |
| 1455 | if (gp) | 1398 | if (gp) |
| 1456 | gates[gatesidx] = gp; | 1399 | gates[gatesidx] = gp; |
| @@ -1458,11 +1401,7 @@ main(argc, argv) | |||
| 1458 | break; | 1401 | break; |
| 1459 | case 'h': | 1402 | case 'h': |
| 1460 | errno = 0; | 1403 | errno = 0; |
| 1461 | #ifdef HAVE_HELP | ||
| 1462 | helpme(); /* exits by itself */ | 1404 | helpme(); /* exits by itself */ |
| 1463 | #else | ||
| 1464 | bail("no help available, dork -- RTFS"); | ||
| 1465 | #endif | ||
| 1466 | case 'i': /* line-interval time */ | 1405 | case 'i': /* line-interval time */ |
| 1467 | o_interval = atoi(optarg) & 0xffff; | 1406 | o_interval = atoi(optarg) & 0xffff; |
| 1468 | if (!o_interval) | 1407 | if (!o_interval) |
| @@ -1508,10 +1447,8 @@ main(argc, argv) | |||
| 1508 | o_wait = atoi(optarg); | 1447 | o_wait = atoi(optarg); |
| 1509 | if (o_wait <= 0) | 1448 | if (o_wait <= 0) |
| 1510 | bail("invalid wait-time %s", optarg); | 1449 | bail("invalid wait-time %s", optarg); |
| 1511 | timer1 = (struct timeval *) Hmalloc(sizeof(struct timeval)); | 1450 | timer1.tv_sec = o_wait; |
| 1512 | timer2 = (struct timeval *) Hmalloc(sizeof(struct timeval)); | 1451 | timer1.tv_usec = 0; |
| 1513 | timer1->tv_sec = o_wait; /* we need two. see | ||
| 1514 | * readwrite()... */ | ||
| 1515 | break; | 1452 | break; |
| 1516 | case 'z': /* little or no data xfer */ | 1453 | case 'z': /* little or no data xfer */ |
| 1517 | o_zero++; | 1454 | o_zero++; |
| @@ -1523,11 +1460,11 @@ main(argc, argv) | |||
| 1523 | } /* while getopt */ | 1460 | } /* while getopt */ |
| 1524 | 1461 | ||
| 1525 | /* other misc initialization */ | 1462 | /* other misc initialization */ |
| 1526 | Debug(("fd_set size %d", sizeof(*ding1))) /* how big *is* it? */ | 1463 | Debug(("fd_set size %d", sizeof(*fds1))) /* how big *is* it? */ |
| 1527 | FD_SET(0, ding1); /* stdin *is* initially open */ | 1464 | FD_SET(0, &fds1); /* stdin *is* initially open */ |
| 1528 | if (o_random) { | 1465 | if (o_random) { |
| 1529 | SRAND(time(0)); | 1466 | SRAND(time(0)); |
| 1530 | randports = Hmalloc(65536); /* big flag array for ports */ | 1467 | randports = calloc(1, 65536); /* big flag array for ports */ |
| 1531 | } | 1468 | } |
| 1532 | #ifdef GAPING_SECURITY_HOLE | 1469 | #ifdef GAPING_SECURITY_HOLE |
| 1533 | if (pr00gie) { | 1470 | if (pr00gie) { |
| @@ -1540,7 +1477,7 @@ main(argc, argv) | |||
| 1540 | ofd = open(stage, O_WRONLY | O_CREAT | O_TRUNC, 0664); | 1477 | ofd = open(stage, O_WRONLY | O_CREAT | O_TRUNC, 0664); |
| 1541 | if (ofd <= 0) /* must be > extant 0/1/2 */ | 1478 | if (ofd <= 0) /* must be > extant 0/1/2 */ |
| 1542 | bail("can't open %s", stage); | 1479 | bail("can't open %s", stage); |
| 1543 | stage = (unsigned char *) Hmalloc(100); | 1480 | stage = (unsigned char *) calloc(1, 100); |
| 1544 | } | 1481 | } |
| 1545 | /* optind is now index of first non -x arg */ | 1482 | /* optind is now index of first non -x arg */ |
| 1546 | Debug(("after go: x now %c, optarg %x optind %d", x, optarg, optind)) | 1483 | Debug(("after go: x now %c, optarg %x optind %d", x, optarg, optind)) |
| @@ -1674,9 +1611,8 @@ main(argc, argv) | |||
| 1674 | if (Single) | 1611 | if (Single) |
| 1675 | exit(x); /* give us status on one connection */ | 1612 | exit(x); /* give us status on one connection */ |
| 1676 | exit(0); /* otherwise, we're just done */ | 1613 | exit(0); /* otherwise, we're just done */ |
| 1677 | } /* main */ | 1614 | } |
| 1678 | 1615 | ||
| 1679 | #ifdef HAVE_HELP /* unless we wanna be *really* cryptic */ | ||
| 1680 | /* helpme : | 1616 | /* helpme : |
| 1681 | the obvious */ | 1617 | the obvious */ |
| 1682 | helpme() | 1618 | helpme() |
| @@ -1714,7 +1650,4 @@ options:"); | |||
| 1714 | -w secs timeout for connects and final net reads\n\ | 1650 | -w secs timeout for connects and final net reads\n\ |
| 1715 | -z zero-I/O mode [used for scanning]"); | 1651 | -z zero-I/O mode [used for scanning]"); |
| 1716 | bail("port numbers can be individual or ranges: lo-hi [inclusive]"); | 1652 | bail("port numbers can be individual or ranges: lo-hi [inclusive]"); |
| 1717 | } /* helpme */ | 1653 | } |
| 1718 | #endif /* HAVE_HELP */ | ||
| 1719 | |||
| 1720 | /* None genuine without this seal! _H*/ | ||
