diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2017-02-04 23:08:35 +0000 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2017-02-26 15:39:29 +0100 |
commit | 55d93d5537a1f8a990d82988e04e68100e876f3d (patch) | |
tree | 0a79e200630a468c703639f2dbb55073b19150f8 | |
parent | 871173992c12561c3a39eeb34701d66e6f4766ea (diff) | |
download | slirp-2.9.0-rc1.zip slirp-2.9.0-rc1.tar.gz slirp-2.9.0-rc1.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.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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 |