diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-03-08 18:34:43 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-03-08 18:34:43 +0000 |
commit | 89319c327aab18dce2217d74aae8d08141d38ac8 (patch) | |
tree | 8c49d48d70b4274fd14414e30348bba41d2ed305 /lib | |
parent | c65b3841ae0590de23f8680c1c027f30a1f16150 (diff) |
do not trash errno before using it, do not pass garbage args to getnameinfo
ok henning andrushock@korovino.net
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/net/rcmd.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/libc/net/rcmd.c b/lib/libc/net/rcmd.c index 4aa32611332..96d62567607 100644 --- a/lib/libc/net/rcmd.c +++ b/lib/libc/net/rcmd.c @@ -29,7 +29,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: rcmd.c,v 1.50 2005/03/07 20:00:15 deraadt Exp $"; +static char *rcsid = "$OpenBSD: rcmd.c,v 1.51 2005/03/08 18:34:42 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/param.h> @@ -244,6 +244,14 @@ again: goto bad; } s3 = accept(s2, (struct sockaddr *)&from, &len); + if (s3 < 0) { + (void)fprintf(stderr, + "rcmd: accept: %s\n", strerror(errno)); + lport = 0; + close(s2); + goto bad; + } + /* * XXX careful for ftp bounce attacks. If discovered, shut them * down and check for the real auxiliary channel to connect. @@ -262,12 +270,7 @@ again: break; } (void)close(s2); - if (s3 < 0) { - (void)fprintf(stderr, - "rcmd: accept: %s\n", strerror(errno)); - lport = 0; - goto bad; - } + *fd2p = s3; switch (from.ss_family) { case AF_INET: |