There are three outstanding Coverity issues for the slirp code. This patchset fixes them: * easiest first, we explicitly check for so->s == -1 in slirp_send() to avoid possibly passing -1 to the send() function. In an ideal world we could assert() it wasn't -1, but the slirp code is too complicated to be sure... * we render a bug in an error-handling codepath moot by switching socreate() to use g_new() rather than malloc(), which means it can no longer fail and we can delete all the error-handling code * last and most complicated, we fix a lack of error handling and possible deadlock in fork_exec() by moving the child socket creation and connect to before fork(), where we can handle the errors appropriately
Tested with an aarch64 Linux guest which I got to do various networky things including an 'apt-get update' and downloading some packages. Also tested the '-net user,smb=/some/dir' which is the most common use of the fork_exec() codepath. I've taken the usual approach of "fix up the indentation only locally so as to placate checkpatch" with this patchset. Happy to adjust if you have some other preference. (I'm veering towards the opinion that at some point we should just say "globally reindent slirp/, because the piecemeal approach hasn't in practice resulted in a very good outcome"; but that's up to you.) Peter Maydell (4): slirp: Don't pass possibly -1 fd to send() slirp: Use g_new() to allocate sockets in socreate() slirp: Remove code that handles socreate() failure slirp: fork_exec(): create and connect child socket before fork() slirp/ip_icmp.c | 2 +- slirp/misc.c | 55 +++++++++++++++++++++++++++++------------------ slirp/slirp.c | 14 +++++++++--- slirp/socket.c | 17 ++++++--------- slirp/tcp_input.c | 7 +++--- slirp/tcp_subr.c | 7 +----- slirp/udp.c | 6 ------ slirp/udp6.c | 3 --- 8 files changed, 56 insertions(+), 55 deletions(-) -- 2.19.1