]> git.proxmox.com Git - mirror_qemu.git/commitdiff
slirp: Check qemu_socket() return value in udp_listen()
authorPeter Maydell <peter.maydell@linaro.org>
Sat, 4 Feb 2017 23:08:33 +0000 (23:08 +0000)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Sun, 26 Feb 2017 14:38:38 +0000 (15:38 +0100)
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

index 93d72247920dabe2b845d191ebd53a03dab9e2e4..227d779022521bd3a170d41f0bcf65000435aeae 100644 (file)
@@ -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);