From 75d638ac9cc613f39ec4513d3dc2e43a6f909da1 Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Sun, 30 Aug 2026 12:58:43 +0200 Subject: fix(udp): receive(0) tests and bad call to getnameinfo --- src/wsocket.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/wsocket.c') diff --git a/src/wsocket.c b/src/wsocket.c index 86c6994..b2b668c 100644 --- a/src/wsocket.c +++ b/src/wsocket.c @@ -286,6 +286,14 @@ int socket_recvfrom(p_socket ps, char *data, size_t count, size_t *got, } if (taken == 0) return IO_CLOSED; err = WSAGetLastError(); + /* a zero-length request is trivially "too small" for any + * non-empty datagram; unlike POSIX, which truncates and succeeds + * silently, Windows reports this as WSAEMSGSIZE even though the + * datagram -- and its sender's address, already written to addr/ + * len above -- was still consumed. Normalize it to match POSIX's + * silent-truncation instead of surfacing a platform-specific + * error for what is otherwise a successful, if empty, receive. */ + if (count == 0 && err == WSAEMSGSIZE) return IO_DONE; /* On UDP, a connreset simply means the previous send failed. * So we try again. * On TCP, it means our socket is now useless, so the error passes. -- cgit v1.2.3-55-g6feb