aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2017-02-04 23:08:35 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2017-02-26 15:39:29 +0100
commit55d93d5537a1f8a990d82988e04e68100e876f3d (patch)
tree0a79e200630a468c703639f2dbb55073b19150f8
parent871173992c12561c3a39eeb34701d66e6f4766ea (diff)
downloadslirp-2.9.0-rc2.zip
slirp-2.9.0-rc2.tar.gz
slirp-2.9.0-rc2.tar.bz2
slirp: tcp_listen(): Don't try to close() an fd we never openedv2.9.0-rc2v2.9.0-rc1v2.9.0-rc0
Coverity points out (CID 1005725) that an error-exit path in tcp_listen() will try to close(s) even if the reason it got there was that the qemu_socket() failed and s was never opened. Not only that, this isn't even the right function to use, because we need closesocket() to do the right thing on Windows. Change to using the right function and only calling it if needed. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
-rw-r--r--socket.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/socket.c b/socket.c
index f6319ca..1b0b26e 100644
--- a/socket.c
+++ b/socket.c
@@ -718,7 +718,9 @@ struct socket *tcp_listen(Slirp *slirp, uint32_t haddr, u_int hport,
(listen(s, 1) < 0)) {
int tmperrno = errno; /* Don't clobber the real reason we failed */
- close(s);
+ if (s >= 0) {
+ closesocket(s);
+ }
sofree(so);
/* Restore the real errno */
#ifdef _WIN32