summaryrefslogtreecommitdiffstats
path: root/usr.sbin/tftpd
diff options
context:
space:
mode:
authordlg <dlg@openbsd.org>2015-08-20 11:28:15 +0000
committerdlg <dlg@openbsd.org>2015-08-20 11:28:15 +0000
commite22aa73238246709c805db0222e4312e6467efab (patch)
treecfeb18d19b353dc774095e006df3d6c8d53fe9b2 /usr.sbin/tftpd
parentavoid ioctl FIONBIO by passing SOCK_NONBLOCK to the things we get (diff)
downloadwireguard-openbsd-e22aa73238246709c805db0222e4312e6467efab.tar.xz
wireguard-openbsd-e22aa73238246709c805db0222e4312e6467efab.zip
use SOCK_NONBLOCK when making a socket instead of ioctl FIONBIO.
for guenther@
Diffstat (limited to 'usr.sbin/tftpd')
-rw-r--r--usr.sbin/tftpd/tftpd.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/usr.sbin/tftpd/tftpd.c b/usr.sbin/tftpd/tftpd.c
index d73355e3fc9..e983392148e 100644
--- a/usr.sbin/tftpd/tftpd.c
+++ b/usr.sbin/tftpd/tftpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tftpd.c,v 1.28 2015/07/20 04:28:03 dlg Exp $ */
+/* $OpenBSD: tftpd.c,v 1.29 2015/08/20 11:28:15 dlg Exp $ */
/*
* Copyright (c) 2012 David Gwynne <dlg@uq.edu.au>
@@ -389,7 +389,6 @@ rewrite_connect(const char *path)
int s;
struct sockaddr_un remote;
size_t len;
- int on = 1;
rwmap = malloc(sizeof(*rwmap));
if (rwmap == NULL)
@@ -405,7 +404,7 @@ rewrite_connect(const char *path)
TAILQ_INIT(&rwmap->clients);
- s = socket(AF_UNIX, SOCK_STREAM, 0);
+ s = socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0);
if (s == -1)
err(1, "rewrite socket");
@@ -418,9 +417,6 @@ rewrite_connect(const char *path)
if (connect(s, (struct sockaddr *)&remote, len) == -1)
err(1, "%s", path);
- if (ioctl(s, FIONBIO, &on) < 0)
- err(1, "rewrite ioctl(FIONBIO)");
-
rwmap->s = s;
}
@@ -532,7 +528,8 @@ tftpd_listen(const char *addr, const char *port, int family)
}
for (res = res0; res != NULL; res = res->ai_next) {
- s = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+ s = socket(res->ai_family, res->ai_socktype | SOCK_NONBLOCK,
+ res->ai_protocol);
if (s == -1) {
cause = "socket";
cerrno = errno;
@@ -546,9 +543,6 @@ tftpd_listen(const char *addr, const char *port, int family)
continue;
}
- if (ioctl(s, FIONBIO, &on) < 0)
- err(1, "ioctl(FIONBIO)");
-
switch (res->ai_family) {
case AF_INET:
if (setsockopt(s, IPPROTO_IP, IP_RECVDSTADDR,
@@ -671,7 +665,8 @@ tftpd_recv(int fd, short events, void *arg)
if (n < 4)
goto err;
- client->sock = socket(client->ss.ss_family, SOCK_DGRAM, 0);
+ client->sock = socket(client->ss.ss_family,
+ SOCK_DGRAM | SOCK_NONBLOCK, 0);
if (client->sock == -1) {
lwarn("socket");
goto err;
@@ -726,9 +721,6 @@ tftpd_recv(int fd, short events, void *arg)
goto err;
}
- if (ioctl(client->sock, FIONBIO, &on) < 0)
- err(1, "client ioctl(FIONBIO)");
-
tp = (struct tftphdr *)client->buf;
client->opcode = ntohs(tp->th_opcode);
if (client->opcode != RRQ && client->opcode != WRQ) {