From: Vic Lee <llyzs.vic@gmail.com>
To: qemu-devel@nongnu.org
Cc: "Samuel Thibault" <samuel.thibault@gnu.org>,
"Jan Kiszka" <jan.kiszka@siemens.com>,
"Marc-André Lureau" <marcandre.lureau@gmail.com>,
"Vic Lee" <llyzs.vic@gmail.com>
Subject: [Qemu-devel] [PATCH v2] slirp: check for ioctlsocket error and 0-length udp payload.
Date: Fri, 1 Mar 2019 14:48:09 +0800 [thread overview]
Message-ID: <20190301064809.3074-1-llyzs.vic@gmail.com> (raw)
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>
---
slirp/socket.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/slirp/socket.c b/slirp/socket.c
index 4876ea3f31..03266128b1 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((dfd," 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
next reply other threads:[~2019-03-01 6:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-01 6:48 Vic Lee [this message]
2019-03-01 6:52 ` [Qemu-devel] [PATCH v2] slirp: check for ioctlsocket error and 0-length udp payload no-reply
2019-03-02 1:38 ` Samuel Thibault
2019-03-06 23:37 ` no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190301064809.3074-1-llyzs.vic@gmail.com \
--to=llyzs.vic@gmail.com \
--cc=jan.kiszka@siemens.com \
--cc=marcandre.lureau@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=samuel.thibault@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).