summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-08-04 15:58:12 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-08-04 15:58:12 +0000
commitee7bab9d6cb2fb169688b1bc00de303d731d03f4 (patch)
treed42f38ca3fe6ea61150341fba0cc6709e81a0c26 /usr.sbin
parent18f87ef6a3595ce478f0a8f3dfd5b9e10132d233 (diff)
bzero sin, bindresvport
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/timed/timedc/cmds.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/usr.sbin/timed/timedc/cmds.c b/usr.sbin/timed/timedc/cmds.c
index d86faca6508..9c1d8dd11d8 100644
--- a/usr.sbin/timed/timedc/cmds.c
+++ b/usr.sbin/timed/timedc/cmds.c
@@ -36,7 +36,7 @@ static char sccsid[] = "@(#)cmds.c 5.1 (Berkeley) 5/11/93";
#endif /* not lint */
#ifdef sgi
-#ident "$Revision: 1.1 $"
+#ident "$Revision: 1.2 $"
#endif
#include "timedc.h"
@@ -482,7 +482,6 @@ tracing(int argc, char *argv[])
int
priv_resources()
{
- int port;
struct sockaddr_in sin;
sock = socket(AF_INET, SOCK_DGRAM, 0);
@@ -491,19 +490,10 @@ priv_resources()
return(-1);
}
+ bzero(&sin, sizeof sin);
sin.sin_family = AF_INET;
- sin.sin_addr.s_addr = 0;
- for (port = IPPORT_RESERVED - 1; port > IPPORT_RESERVED / 2; port--) {
- sin.sin_port = htons((u_short)port);
- if (bind(sock, (struct sockaddr*)&sin, sizeof (sin)) >= 0)
- break;
- if (errno != EADDRINUSE && errno != EADDRNOTAVAIL) {
- perror("bind");
- (void) close(sock);
- return(-1);
- }
- }
- if (port == IPPORT_RESERVED / 2) {
+ sin.sin_addr.s_addr = INADDR_ANY;
+ if (bindresvport(sock, &sin) < 0) {
fprintf(stderr, "all reserved ports in use\n");
(void) close(sock);
return(-1);