From 4577b09a278fe9134ecb9192c2ae2ed67a0d0aa7 Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Sat, 4 Feb 2017 23:08:33 +0000 Subject: slirp: Check qemu_socket() return value in udp_listen() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Samuel Thibault --- slirp/udp.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'slirp') 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); -- cgit v1.2.1