diff options
author | Vic Lee <llyzs.vic@gmail.com> | 2019-03-01 14:48:09 +0800 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2019-03-06 23:36:19 +0100 |
commit | 6c419a1e06c21c4568d5a12a9c5cafcdb00f6aa8 (patch) | |
tree | 821d7c57b5c6bda191b06adbcf9d07315e0dc0e8 /slirp | |
parent | 8cabd8778c378802adee7d0c3be4e5b5b5be4bee (diff) | |
download | qemu-6c419a1e06c21c4568d5a12a9c5cafcdb00f6aa8.zip qemu-6c419a1e06c21c4568d5a12a9c5cafcdb00f6aa8.tar.gz qemu-6c419a1e06c21c4568d5a12a9c5cafcdb00f6aa8.tar.bz2 |
slirp: check for ioctlsocket error and 0-length udp payload.
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 <llyzs.vic@gmail.com>
Message-Id: <20190301064809.3074-1-llyzs.vic@gmail.com>
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Diffstat (limited to 'slirp')
-rw-r--r-- | slirp/socket.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/slirp/socket.c b/slirp/socket.c index 4876ea3..4dc5e29 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; |