diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1998-07-10 18:22:55 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1998-07-10 18:22:55 +0000 |
commit | 4ec8822c056cfe2dd9931ed26bfd1dd06183400c (patch) | |
tree | a233805eb7dd26bb570a3b2e32b1c480708922b3 | |
parent | 129316b7a95b0cda0e954236f783a3866045ffd4 (diff) |
Make sure port is in allowed range before trying to get a reserved port.
-rw-r--r-- | libexec/rshd/rshd.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/libexec/rshd/rshd.c b/libexec/rshd/rshd.c index 57c364ea8ca..64d472d1798 100644 --- a/libexec/rshd/rshd.c +++ b/libexec/rshd/rshd.c @@ -39,7 +39,7 @@ static char copyright[] = #ifndef lint /* from: static char sccsid[] = "@(#)rshd.c 8.2 (Berkeley) 4/6/94"; */ -static char *rcsid = "$Id: rshd.c,v 1.26 1998/07/10 08:06:12 deraadt Exp $"; +static char *rcsid = "$Id: rshd.c,v 1.27 1998/07/10 18:22:54 millert Exp $"; #endif /* not lint */ /* @@ -306,12 +306,7 @@ doit(fromp) (void) alarm(0); if (port != 0) { - int lport = IPPORT_RESERVED - 1; - s = rresvport(&lport); - if (s < 0) { - syslog(LOG_ERR, "can't get stderr port: %m"); - exit(1); - } + int lport; #ifdef KERBEROS if (!use_kerberos) #endif @@ -321,6 +316,12 @@ doit(fromp) exit(1); } fromp->sin_port = htons(port); + lport = IPPORT_RESERVED - 1; + s = rresvport(&lport); + if (s < 0) { + syslog(LOG_ERR, "can't get stderr port: %m"); + exit(1); + } if (connect(s, (struct sockaddr *)fromp, sizeof (*fromp)) < 0) { syslog(LOG_INFO, "connect second port %d: %m", port); exit(1); |