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 | 3ea1a72ad61865fac3134686d5f4c6b4a17b2a91 (patch) | |
tree | 7181be361516b1ea31a4d5fa13a50b41fb87e097 | |
parent | c0870d703b1c5a7bb6c573c585957751b3971f4e (diff) | |
download | slirp-3ea1a72ad61865fac3134686d5f4c6b4a17b2a91.zip slirp-3ea1a72ad61865fac3134686d5f4c6b4a17b2a91.tar.gz slirp-3ea1a72ad61865fac3134686d5f4c6b4a17b2a91.tar.bz2 |
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>
-rw-r--r-- | misc.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -107,7 +107,9 @@ int 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; } |