From 4af0c6c0bcceab7640b943c56620b11302f6bb9b Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 2 Mar 2013 14:32:54 +0100 Subject: Don't crash on empty UDP packets --- src/fastd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fastd.c b/src/fastd.c index d43784f..380f6a2 100644 --- a/src/fastd.c +++ b/src/fastd.c @@ -780,8 +780,8 @@ static void handle_socket(fastd_context_t *ctx, fastd_socket_t *sock) { socklen_t recvaddrlen = sizeof(recvaddr); ssize_t len = recvfrom(sock->fd, buffer.data, buffer.len, 0, (struct sockaddr*)&recvaddr, &recvaddrlen); - if (len < 0) { - if (errno != EINTR) + if (len <= 0) { + if (len < 0 && errno != EINTR) pr_warn(ctx, "recvfrom: %s", strerror(errno)); fastd_buffer_free(buffer); -- cgit v1.2.3