|
|||||||||||
|
oops... diff for netcat again
From: Andrushock <andrushock(at)korovino.net>
Date: Thu Dec 05 2002 - 17:47:26 EST
- Add checks for calloc, strdup, strsep failure - More clear and detailed output at use errx - "Unix Domain Sockets" -> "UNIX domain sockets" in netcat.c and manpage - KNF
Tested on:
if (lflag && sflag)
- errx(1, "cannot use -s and -l");
+ errx(1, "the -s and -l options may not be specified together");
if (lflag && pflag)
- errx(1, "cannot use -p and -l");
+ errx(1, "the -p and -l options may not be specified together");
if (lflag && zflag)
- errx(1, "cannot use -z and -l");
+ errx(1, "the -z and -l options may not be specified together");
if (!lflag && kflag)
- errx(1, "must use -l with -k");
+ errx(1, "the -l and -k options must be specified together");
/* Initialize addrinfo structure */
if (family != AF_UNIX) {
@@ -362,7 +358,7 @@ /* * unix_connect() - * Return's a socket connected to a local unix socket. Return's -1 on failure. + * Return's a socket connected to a local UNIX socket. Return's -1 on failure. */ int unix_connect(char *path) @@ -387,7 +383,7 @@ /* * unix_listen() - * create a unix domain socket, and listen on it. + * create a UNIX domain socket, and listen on it. */ int unix_listen(char *path) @@ -395,7 +391,7 @@
struct sockaddr_un sun;
int s;
- /* create unix domain socket */
+ /* create UNIX domain socket */
if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
return (-1);
@@ -655,7 +650,8 @@
/* Load ports sequentially */
for (cp = lo; cp <= hi; cp++) {
- portlist[x] = calloc(1, PORT_MAX);
+ if ((portlist[x] = calloc(1, PORT_MAX)) == NULL)
+ err(1, "calloc");
snprintf(portlist[x], PORT_MAX, "%d", cp);
x++;
}
} @@ -702,7 +699,7 @@ }
void
usage(0);
fprintf(stderr, "\tCommand Summary:\n\
@@ -731,9 +728,13 @@ void usage(int ret) {
- fprintf(stderr, "usage: nc [-46Uhklnrtuvz] [-i interval] [-p source port]\n");
- fprintf(stderr, "\t [-s ip address] [-w timeout] [-X vers] [-x proxy address [:port]]\n");
- fprintf(stderr, "\t [hostname] [port[s...]]\n");
+ extern char *__progname; /* from crt0.o */
+
+ fprintf(stderr,
+ "usage: %s [-46Uhklnrtuvz] [-i interval] [-p source port]\n"
+ "\t [-s ip address] [-w timeout] [-X vers] [-x proxy address [:port]]\n"
+ "\t [hostname] [port[s...]]\n", __progname);
+
if (ret)
exit(1);
} --- src/usr.bin/nc/socks.c.orig Thu Dec 5 06:15:49 2002 +++ src/usr.bin/nc/socks.c Fri Dec 6 00:25:26 2002 @@ -59,9 +59,9 @@ struct in_addr retval;
if (hp)
- return *(in_addr_t *)hp->h_addr_list[0];
+ return (*(in_addr_t *)hp->h_addr_list[0]);
if (inet_aton (s, &retval))
- return retval.s_addr;
+ return (retval.s_addr);
errx (1, "cannot decode address \"%s\"", s);
}
@@ -74,12 +74,11 @@
port = strtol (s, &p, 10);
if (s == p) {
- sp = getservbyname (s, "tcp");
- if (sp)
- return sp->s_port;
+ if (sp = getservbyname (s, "tcp"))
+ return (sp->s_port);
}
if (*s != '\0' && *p == '\0')
- return htons (port);
+ return (htons (port));
errx (1, "cannot decode port \"%s\"", s);
}
proxyfd = remote_connect(proxyhost, SOCKS_PORT, proxyhints);
if (!proxyfd)
- return -1;
+ return (-1);
serveraddr = decode_addr (host);
serverport = decode_port (port);
} --- src/usr.bin/nc/nc.1.orig Fri Dec 6 00:41:34 2002 +++ src/usr.bin/nc/nc.1 Fri Dec 6 01:42:46 2002 @@ -141,7 +141,7 @@ .Nm should just scan for listening daemons, without sending any data to them. .It Fl U -Specifies to use Unix Domain Sockets. +Specifies to use UNIX domain sockets. .It Fl X Ar version Requests that .Nm @@ -183,9 +183,9 @@ followed by a newline, and move data from port 1000 of hostname to stdout until hostname closes the connection. .It Li "$ nc -U /var/tmp/dsocket" -Connect to a Unix Domain Socket. +Connect to a UNIX domain socket. .It Li "$ nc -lU /var/tmp/dsocket" -Create and listen on a Unix Domain Socket. +Create and listen on a UNIX domain socket. .El .Sh SEE ALSO .Xr cat 1 ,Received on Fri Dec 6 17:49:40 2002 This archive was generated by hypermail 2.1.8 : Wed Aug 23 2006 - 13:29:38 EDT |
||||||||||
|
|||||||||||