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 | 4577b09a278fe9134ecb9192c2ae2ed67a0d0aa7 (patch) | |
tree | c803fbec793c9c5949b8f17fe1f29d4761070cf7 /slirp | |
parent | 6528a4c1f20c1ba5a22ab84bec6788a574ac04c8 (diff) |
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>
Diffstat (limited to 'slirp')
-rw-r--r-- | slirp/udp.c | 4 |
1 files changed, 4 insertions, 0 deletions
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); |