summaryrefslogtreecommitdiff
path: root/src/lib/libc/net/rcmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc/net/rcmd.c')
-rw-r--r--src/lib/libc/net/rcmd.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/lib/libc/net/rcmd.c b/src/lib/libc/net/rcmd.c
index 22a956cfb0..28420d20eb 100644
--- a/src/lib/libc/net/rcmd.c
+++ b/src/lib/libc/net/rcmd.c
@@ -228,21 +228,19 @@ rresvport(alport)
228 s = socket(AF_INET, SOCK_STREAM, 0); 228 s = socket(AF_INET, SOCK_STREAM, 0);
229 if (s < 0) 229 if (s < 0)
230 return (-1); 230 return (-1);
231 for (;;) { 231 sin.sin_port = htons((u_short)*alport);
232 sin.sin_port = htons((u_short)*alport); 232 if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0)
233 if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0) 233 return (s);
234 return (s); 234 if (errno != EADDRINUSE) {
235 if (errno != EADDRINUSE) { 235 (void)close(s);
236 (void)close(s); 236 return (-1);
237 return (-1);
238 }
239 (*alport)--;
240 if (*alport == IPPORT_RESERVED/2) {
241 (void)close(s);
242 errno = EAGAIN; /* close */
243 return (-1);
244 }
245 } 237 }
238 if (bindresvport(s, &sin) == -1) {
239 (void)close(s);
240 return (-1);
241 }
242 *alport = (int)ntohs(sin.sin_port);
243 return (s);
246} 244}
247 245
248int __check_rhosts_file = 1; 246int __check_rhosts_file = 1;