From 4ec8822c056cfe2dd9931ed26bfd1dd06183400c Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Fri, 10 Jul 1998 18:22:55 +0000 Subject: Make sure port is in allowed range before trying to get a reserved port. --- libexec/rshd/rshd.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'libexec/rshd') 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); -- cgit v1.2.3