aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2017-02-04 23:08:33 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2017-02-26 15:38:38 +0100
commit095b668955879fbe54c7ec5ae5a173946566f0fa (patch)
tree6382774b213f574deaff0b9a396fd45659873481
parentdcc625767f8f823a0ca2e790d75d78c90ba67256 (diff)
downloadslirp-095b668955879fbe54c7ec5ae5a173946566f0fa.zip
slirp-095b668955879fbe54c7ec5ae5a173946566f0fa.tar.gz
slirp-095b668955879fbe54c7ec5ae5a173946566f0fa.tar.bz2
slirp: Check qemu_socket() return value in udp_listen()
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>
-rw-r--r--udp.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/udp.c b/udp.c
index fde0585..e46b1c8 100644
--- a/udp.c
+++ b/udp.c
@@ -326,6 +326,10 @@ struct socket *udp_listen(Slirp *slirp, uint32_t haddr, u_int hport,
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);