summaryrefslogtreecommitdiff
path: root/usr.sbin/ypbind
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2016-03-21 00:49:37 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2016-03-21 00:49:37 +0000
commit480dc4adde06fe54aa2665b9b4089af30a42820d (patch)
treec2567b64123939d7200344008a7006c9dabfd254 /usr.sbin/ypbind
parentd4c8db29044b848271e1a2a3de2d895b0df21c40 (diff)
Instead of creating a socket with socket() or accept() and then
setting the O_NONBLOCK flag on it with fcntl(F_SETFL) afterwards, just pass SOCK_NONBLOCK to socket() or accept4() and get it right to begin with. ok millert@ krw@ beck@ deraadt@ jca@
Diffstat (limited to 'usr.sbin/ypbind')
-rw-r--r--usr.sbin/ypbind/ypbind.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/usr.sbin/ypbind/ypbind.c b/usr.sbin/ypbind/ypbind.c
index e4b78df3d00..9c4aef0e470 100644
--- a/usr.sbin/ypbind/ypbind.c
+++ b/usr.sbin/ypbind/ypbind.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ypbind.c,v 1.65 2015/12/12 20:04:23 mmcc Exp $ */
+/* $OpenBSD: ypbind.c,v 1.66 2016/03/21 00:49:36 guenther Exp $ */
/*
* Copyright (c) 1992, 1993, 1996, 1997, 1998 Theo de Raadt <deraadt@openbsd.org>
@@ -475,7 +475,7 @@ main(int argc, char *argv[])
}
}
- if ((rpcsock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
+ if ((rpcsock = socket(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK, 0)) < 0) {
perror("socket");
return -1;
}
@@ -485,7 +485,7 @@ main(int argc, char *argv[])
sin.sin_port = 0;
bindresvport(rpcsock, &sin);
- if ((pingsock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
+ if ((pingsock = socket(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK, 0)) < 0) {
perror("socket");
return -1;
}
@@ -495,8 +495,6 @@ main(int argc, char *argv[])
sin.sin_port = 0;
bindresvport(pingsock, &sin);
- fcntl(rpcsock, F_SETFL, fcntl(rpcsock, F_GETFL, 0) | FNDELAY);
- fcntl(pingsock, F_SETFL, fcntl(pingsock, F_GETFL, 0) | FNDELAY);
setsockopt(rpcsock, SOL_SOCKET, SO_BROADCAST, &one,
(socklen_t)sizeof(one));
rmtca.prog = YPPROG;