From 2abf42515b41f9f996cc683096af9ed0d5c85fce Mon Sep 17 00:00:00 2001 From: Cthulhu-throwaway <96153783+Cthulhu-throwaway@users.noreply.github.com> Date: Wed, 1 Jun 2022 03:24:46 -0300 Subject: [PATCH] (UPnP) Fix for zero-length datagrams --- network/natt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/network/natt.c b/network/natt.c index cf5be9ebfd..92736c6d3a 100644 --- a/network/natt.c +++ b/network/natt.c @@ -194,8 +194,12 @@ bool natt_device_next(struct natt_discovery *discovery, recvd = recvfrom(discovery->fd, buf, sizeof(buf), 0, (struct sockaddr *) &device->addr, &addr_size); - if (recvd <= 0) + if (recvd < 0) return false; + /* Zero-length datagrams are valid, but we can't do anything with them. + Don't treat them as an error. */ + if (!recvd) + return true; /* Parse the data we received. We are only looking for the 'Location' HTTP header. */