diff mbox series

[PULL,1/3] slirp: Check qemu_socket() return value in udp_listen()

Message ID 20170226144353.2502-2-samuel.thibault@ens-lyon.org
State Accepted
Commit 4577b09a278fe9134ecb9192c2ae2ed67a0d0aa7
Headers show
Series [PULL,1/3] slirp: Check qemu_socket() return value in udp_listen() | expand

Commit Message

Samuel Thibault Feb. 26, 2017, 2:43 p.m. UTC
From: Peter Maydell <peter.maydell@linaro.org>


Check the return value from qemu_socket() rather than trying to
pass it to bind() as an fd argument even if it's negative.
This wouldn't have caused any negative consequences, because
it won't be a valid fd number and the bind call will fail;
but Coverity complains (CID 1005723).

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>

---
 slirp/udp.c | 4 ++++
 1 file changed, 4 insertions(+)

-- 
2.11.0
diff mbox series

Patch

diff --git a/slirp/udp.c b/slirp/udp.c
index 93d7224792..227d779022 100644
--- a/slirp/udp.c
+++ b/slirp/udp.c
@@ -335,6 +335,10 @@  udp_listen(Slirp *slirp, uint32_t haddr, u_int hport, uint32_t laddr,
 	    return NULL;
 	}
 	so->s = qemu_socket(AF_INET,SOCK_DGRAM,0);
+        if (so->s < 0) {
+            sofree(so);
+            return NULL;
+        }
 	so->so_expire = curtime + SO_EXPIRE;
 	insque(so, &slirp->udb);