From 4484273238305effa4b21831172932446fa6f985 Mon Sep 17 00:00:00 2001 From: Juliusz Sosinowicz Date: Thu, 24 Sep 2026 12:50:17 +0000 Subject: [PATCH] F-13971: ignore zero-length datagrams in the DTLS demux server recvfrom() returns 0 for an empty UDP datagram. The server treated that as fatal, so any peer could stop it with a single empty packet. Also retry EINTR/EAGAIN and report other receive errors. --- dtls/server-dtls-demux.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dtls/server-dtls-demux.c b/dtls/server-dtls-demux.c index e4bd8c281..3446384af 100644 --- a/dtls/server-dtls-demux.c +++ b/dtls/server-dtls-demux.c @@ -316,8 +316,15 @@ int main(void) struct ConnList *conn = NULL; sz = recvfrom(listenfd.fd, readBuf, sizeof(readBuf), 0, &peerAddr, &peerAddrLen); - if (sz <= 0) + if (sz < 0) { + if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) + continue; + perror("recvfrom"); goto cleanup; + } + /* Empty datagrams are valid UDP. Drop them. */ + if (sz == 0) + continue; /* find ssl object */ conn = findConn(connList, readBuf, sz, &peerAddr, peerAddrLen);