diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2017-02-04 23:08:33 +0000 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2017-02-26 15:38:38 +0100 |
commit | 095b668955879fbe54c7ec5ae5a173946566f0fa (patch) | |
tree | 6382774b213f574deaff0b9a396fd45659873481 | |
parent | dcc625767f8f823a0ca2e790d75d78c90ba67256 (diff) | |
download | slirp-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.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -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); |