diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2017-07-09 18:54:22 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2017-07-15 14:28:25 +0200 |
commit | 12dccfe4f57ead8166567ec8a60d2ce91e266f04 (patch) | |
tree | 8b6d6ca19237f9d1e1217e4f15a8200257a2b68a /slirp | |
parent | e88718fc0b0399147327adfb369793407482a895 (diff) |
slirp: fork_exec(): Don't close() a negative number in fork_exec()
In a fork_exec() error path we try to closesocket(s) when s might
be a negative number because the thing that failed was the
qemu_socket() call. Add a guard so we don't do this.
(Spotted by Coverity: CID 1005727 issue 1 of 2.)
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Diffstat (limited to 'slirp')
-rw-r--r-- | slirp/misc.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/slirp/misc.c b/slirp/misc.c index 88e9d94197..260187b6b6 100644 --- a/slirp/misc.c +++ b/slirp/misc.c @@ -112,7 +112,9 @@ fork_exec(struct socket *so, const char *ex, int do_pty) bind(s, (struct sockaddr *)&addr, addrlen) < 0 || listen(s, 1) < 0) { error_report("Error: inet socket: %s", strerror(errno)); - closesocket(s); + if (s >= 0) { + closesocket(s); + } return 0; } |