From 9c32f38dea0489996f18e12c75445b7e11c6c4a1 Mon Sep 17 00:00:00 2001 From: Tomasz Ostrowski <43222462+tomek-o@users.noreply.github.com> Date: Sat, 1 Jul 2023 19:32:58 +0200 Subject: [PATCH] Fix fspr_socket_recv when receiving UDP with no data --- libs/apr/network_io/beos/sendrecv.c | 5 +++-- libs/apr/network_io/os2/sendrecv.c | 5 ++++- libs/apr/network_io/unix/sendrecv.c | 3 ++- libs/apr/network_io/win32/sendrecv.c | 5 ++++- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/libs/apr/network_io/beos/sendrecv.c b/libs/apr/network_io/beos/sendrecv.c index 618b2c6a8b..eff9494c85 100644 --- a/libs/apr/network_io/beos/sendrecv.c +++ b/libs/apr/network_io/beos/sendrecv.c @@ -117,8 +117,9 @@ APR_DECLARE(fspr_status_t) fspr_socket_recv(fspr_socket_t *sock, char *buf, return errno; } (*len) = rv; - if (rv == 0) + if (rv == 0 && sock->type == SOCK_STREAM) return APR_EOF; + return APR_SUCCESS; } @@ -205,7 +206,7 @@ APR_DECLARE(fspr_status_t) fspr_socket_recvfrom(fspr_sockaddr_t *from, } (*len) = rv; - if (rv == 0) + if (rv == 0 && sock->type == SOCK_STREAM) return APR_EOF; return APR_SUCCESS; diff --git a/libs/apr/network_io/os2/sendrecv.c b/libs/apr/network_io/os2/sendrecv.c index 8f0fbf805c..16ff823e7a 100644 --- a/libs/apr/network_io/os2/sendrecv.c +++ b/libs/apr/network_io/os2/sendrecv.c @@ -100,7 +100,10 @@ APR_DECLARE(fspr_status_t) fspr_socket_recv(fspr_socket_t *sock, char *buf, } (*len) = rv; - return rv == 0 ? APR_EOF : APR_SUCCESS; + if (rv == 0 && sock->type == SOCK_STREAM) + return APR_EOF; + + return APR_SUCCESS; } diff --git a/libs/apr/network_io/unix/sendrecv.c b/libs/apr/network_io/unix/sendrecv.c index 2015bf0bfc..64a83c344e 100644 --- a/libs/apr/network_io/unix/sendrecv.c +++ b/libs/apr/network_io/unix/sendrecv.c @@ -105,9 +105,10 @@ do_select: sock->options |= APR_INCOMPLETE_READ; } (*len) = rv; - if (rv == 0) { + if (rv == 0 && sock->type == SOCK_STREAM) { return APR_EOF; } + return APR_SUCCESS; } diff --git a/libs/apr/network_io/win32/sendrecv.c b/libs/apr/network_io/win32/sendrecv.c index 63891a50c6..897c6f6371 100644 --- a/libs/apr/network_io/win32/sendrecv.c +++ b/libs/apr/network_io/win32/sendrecv.c @@ -90,7 +90,10 @@ APR_DECLARE(fspr_status_t) fspr_socket_recv(fspr_socket_t *sock, char *buf, } *len = dwBytes; - return dwBytes == 0 ? APR_EOF : APR_SUCCESS; + if (rv == 0 && sock->type == SOCK_STREAM) + return APR_EOF; + + return APR_SUCCESS; }