[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULLv2 02/12] slirp: check for ioctlsocket error and 0-len
From: |
Samuel Thibault |
Subject: |
[Qemu-devel] [PULLv2 02/12] slirp: check for ioctlsocket error and 0-length udp payload. |
Date: |
Thu, 7 Mar 2019 12:51:33 +0100 |
From: Vic Lee <address@hidden>
Sometimes sorecvfrom() is called from slirp.c because revents == G_IO_IN,
but there is 0 bytes available and recvfrom could be blocking indefinitely.
This is likely due to 0-length udp payload. This also adds an error
checking for ioctlsocket.
Signed-off-by: Vic Lee <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Samuel Thibault <address@hidden>
---
slirp/socket.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/slirp/socket.c b/slirp/socket.c
index 4876ea3f31..4dc5e2907d 100644
--- a/slirp/socket.c
+++ b/slirp/socket.c
@@ -529,6 +529,15 @@ sorecvfrom(struct socket *so)
int n;
#endif
+ if (ioctlsocket(so->s, FIONREAD, &n) != 0) {
+ DEBUG_MISC(" ioctlsocket errno = %d-%s\n",
+ errno,strerror(errno));
+ return;
+ }
+ if (n == 0) {
+ return;
+ }
+
m = m_get(so->slirp);
if (!m) {
return;
@@ -552,7 +561,6 @@ sorecvfrom(struct socket *so)
*/
len = M_FREEROOM(m);
/* if (so->so_fport != htons(53)) { */
- ioctlsocket(so->s, FIONREAD, &n);
if (n > len) {
n = (m->m_data - m->m_dat) + m->m_len + n + 1;
--
2.20.1
- [Qemu-devel] [PULLv2 00/12] slirp updates, Samuel Thibault, 2019/03/07
- [Qemu-devel] [PULLv2 02/12] slirp: check for ioctlsocket error and 0-length udp payload.,
Samuel Thibault <=
- [Qemu-devel] [PULLv2 03/12] slirp: check sscanf result when emulating ident, Samuel Thibault, 2019/03/07
- [Qemu-devel] [PULLv2 05/12] slirp: Mark pieces missing IPv6 support, Samuel Thibault, 2019/03/07
- [Qemu-devel] [PULLv2 08/12] slirp: use "slirp_" prefix for inet_aton() win32 implementation, Samuel Thibault, 2019/03/07
- [Qemu-devel] [PULLv2 04/12] slirp: fix big/little endian conversion in ident protocol, Samuel Thibault, 2019/03/07
- [Qemu-devel] [PULLv2 01/12] slirp: Fix build with gcc 9, Samuel Thibault, 2019/03/07
- [Qemu-devel] [PULLv2 07/12] slirp: use libslirp migration code, Samuel Thibault, 2019/03/07
- [Qemu-devel] [PULLv2 1/1] slirp: remove QEMU Makefile.objs, Samuel Thibault, 2019/03/07
- [Qemu-devel] [PULLv2 12/12] slirp: remove QEMU Makefile.objs, Samuel Thibault, 2019/03/07
- [Qemu-devel] [PULLv2 09/12] slirp: move sources to src/ subdirectory, Samuel Thibault, 2019/03/07
- [Qemu-devel] [PULLv2 10/12] slirp: add a standalone Makefile, Samuel Thibault, 2019/03/07