Merge pull request #13995 from Cthulhu-throwaway/natt-fix

(UPnP) Fix for zero-length datagrams
This commit is contained in:
LibretroAdmin 2022-06-01 07:37:28 +01:00 committed by GitHub
commit 6755eac963
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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. */