slirp/socket.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
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
Patchew URL: https://patchew.org/QEMU/20190301064809.3074-1-llyzs.vic@gmail.com/
Hi,
This series seems to have some coding style problems. See output below for
more information:
Message-id: 20190301064809.3074-1-llyzs.vic@gmail.com
Subject: [Qemu-devel] [PATCH v2] slirp: check for ioctlsocket error and 0-length udp payload.
Type: series
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
* [new tag] patchew/20190301064809.3074-1-llyzs.vic@gmail.com -> patchew/20190301064809.3074-1-llyzs.vic@gmail.com
Switched to a new branch 'test'
0987e4851f slirp: check for ioctlsocket error and 0-length udp payload.
=== OUTPUT BEGIN ===
ERROR: code indent should never use tabs
#23: FILE: slirp/socket.c:532:
+^I if (ioctlsocket(so->s, FIONREAD, &n) != 0) {$
ERROR: suspect code indent for conditional statements (10, 14)
#23: FILE: slirp/socket.c:532:
+ if (ioctlsocket(so->s, FIONREAD, &n) != 0) {
+ DEBUG_MISC((dfd," ioctlsocket errno = %d-%s\n",
ERROR: code indent should never use tabs
#24: FILE: slirp/socket.c:533:
+^I DEBUG_MISC((dfd," ioctlsocket errno = %d-%s\n",$
ERROR: space required after that ',' (ctx:VxV)
#24: FILE: slirp/socket.c:533:
+ DEBUG_MISC((dfd," ioctlsocket errno = %d-%s\n",
^
ERROR: code indent should never use tabs
#25: FILE: slirp/socket.c:534:
+^I^I^I errno,strerror(errno)));$
ERROR: space required after that ',' (ctx:VxV)
#25: FILE: slirp/socket.c:534:
+ errno,strerror(errno)));
^
ERROR: code indent should never use tabs
#26: FILE: slirp/socket.c:535:
+^I return;$
ERROR: code indent should never use tabs
#27: FILE: slirp/socket.c:536:
+^I }$
ERROR: code indent should never use tabs
#28: FILE: slirp/socket.c:537:
+^I if (n == 0) {$
ERROR: suspect code indent for conditional statements (10, 14)
#28: FILE: slirp/socket.c:537:
+ if (n == 0) {
+ return;
ERROR: code indent should never use tabs
#29: FILE: slirp/socket.c:538:
+^I return;$
ERROR: code indent should never use tabs
#30: FILE: slirp/socket.c:539:
+^I }$
total: 12 errors, 0 warnings, 22 lines checked
Commit 0987e4851f60 (slirp: check for ioctlsocket error and 0-length udp payload.) has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/20190301064809.3074-1-llyzs.vic@gmail.com/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
Vic Lee, le ven. 01 mars 2019 14:48:09 +0800, a ecrit: > 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> Applied to my tree, thanks! Samuel
Patchew URL: https://patchew.org/QEMU/20190301064809.3074-1-llyzs.vic@gmail.com/
Hi,
This series failed the docker-mingw@fedora build test. Please find the testing commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.
=== TEST SCRIPT BEGIN ===
#!/bin/bash
time make docker-test-mingw@fedora SHOW_ENV=1 J=14 NETWORK=1
=== TEST SCRIPT END ===
from /tmp/qemu-test/src/slirp/slirp.h:50,
from /tmp/qemu-test/src/slirp/socket.c:8:
/tmp/qemu-test/src/slirp/socket.c: In function 'sorecvfrom':
/tmp/qemu-test/src/slirp/socket.c:533:20: error: 'dfd' undeclared (first use in this function)
DEBUG_MISC((dfd," ioctlsocket errno = %d-%s\n",
^~~
/usr/x86_64-w64-mingw32/sys-root/mingw/include/glib-2.0/glib/gmessages.h:345:32: note: in definition of macro 'g_debug'
---
/tmp/qemu-test/src/slirp/socket.c:533:8: note: in expansion of macro 'DEBUG_MISC'
DEBUG_MISC((dfd," ioctlsocket errno = %d-%s\n",
^~~~~~~~~~
/tmp/qemu-test/src/slirp/socket.c:533:23: error: left-hand operand of comma expression has no effect [-Werror=unused-value]
DEBUG_MISC((dfd," ioctlsocket errno = %d-%s\n",
^
/usr/x86_64-w64-mingw32/sys-root/mingw/include/glib-2.0/glib/gmessages.h:345:32: note: in definition of macro 'g_debug'
---
/tmp/qemu-test/src/slirp/socket.c:533:8: note: in expansion of macro 'DEBUG_MISC'
DEBUG_MISC((dfd," ioctlsocket errno = %d-%s\n",
^~~~~~~~~~
/tmp/qemu-test/src/slirp/socket.c:533:54: error: left-hand operand of comma expression has no effect [-Werror=unused-value]
DEBUG_MISC((dfd," ioctlsocket errno = %d-%s\n",
^
/usr/x86_64-w64-mingw32/sys-root/mingw/include/glib-2.0/glib/gmessages.h:345:32: note: in definition of macro 'g_debug'
---
/tmp/qemu-test/src/slirp/socket.c:533:8: note: in expansion of macro 'DEBUG_MISC'
DEBUG_MISC((dfd," ioctlsocket errno = %d-%s\n",
^~~~~~~~~~
/tmp/qemu-test/src/slirp/socket.c:533:8: error: format not a string literal and no format arguments [-Werror=format-security]
cc1: all warnings being treated as errors
make: *** [/tmp/qemu-test/src/rules.mak:69: slirp/socket.o] Error 1
Traceback (most recent call last):
The full log is available at
http://patchew.org/logs/20190301064809.3074-1-llyzs.vic@gmail.com/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
© 2016 - 2026 Red Hat, Inc.