summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/sd-dhcp-server.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-02-15 22:50:01 +0100
committerLennart Poettering <lennart@poettering.net>2016-02-16 13:06:55 +0100
commit4edc2c9b6b5b921873eb82e58719ed4d9e0d69bf (patch)
tree442a5560b9fc2c187c8dc6aa982733ff72e54c94 /src/libsystemd-network/sd-dhcp-server.c
parent11ab173d4067a4ed6fab811ba2159456053fd4c1 (diff)
networkd: FIONREAD is not reliable on some sockets
Fixes: #2457
Diffstat (limited to 'src/libsystemd-network/sd-dhcp-server.c')
-rw-r--r--src/libsystemd-network/sd-dhcp-server.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/libsystemd-network/sd-dhcp-server.c b/src/libsystemd-network/sd-dhcp-server.c
index ad3a37b722..54ff1a3f28 100644
--- a/src/libsystemd-network/sd-dhcp-server.c
+++ b/src/libsystemd-network/sd-dhcp-server.c
@@ -955,14 +955,13 @@ static int server_receive_message(sd_event_source *s, int fd,
.msg_controllen = sizeof(cmsgbuf),
};
struct cmsghdr *cmsg;
- int buflen = 0, len;
+ ssize_t buflen, len;
assert(server);
- if (ioctl(fd, FIONREAD, &buflen) < 0)
- return -errno;
- else if (buflen < 0)
- return -EIO;
+ buflen = next_datagram_size_fd(fd);
+ if (buflen < 0)
+ return buflen;
message = malloc(buflen);
if (!message)