qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] net/socket: fix coverity issue
@ 2017-11-06 13:28 Jens Freimann
  2017-11-06 13:29 ` Peter Maydell
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Jens Freimann @ 2017-11-06 13:28 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, jasowang

This fixes coverity issue CID1005339.

Make sure that saddr is not used uninitialized if the
mcast parameter is NULL.

Cc: qemu-stable@nongnu.org
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Jens Freimann <jfreimann@redhat.com>
---
 net/socket.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/socket.c b/net/socket.c
index e6b471c63d..51eaea67a0 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -332,7 +332,7 @@ static NetSocketState *net_socket_fd_init_dgram(NetClientState *peer,
                                                 const char *mcast,
                                                 Error **errp)
 {
-    struct sockaddr_in saddr;
+    struct sockaddr_in saddr = { 0 };
     int newfd;
     NetClientState *nc;
     NetSocketState *s;
@@ -373,7 +373,7 @@ static NetSocketState *net_socket_fd_init_dgram(NetClientState *peer,
     net_socket_read_poll(s, true);
 
     /* mcast: save bound address as dst */
-    if (is_connected) {
+    if (is_connected && mcast != NULL) {
         s->dgram_dst = saddr;
         snprintf(nc->info_str, sizeof(nc->info_str),
                  "socket: fd=%d (cloned mcast=%s:%d)",
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-11-13 10:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-06 13:28 [Qemu-devel] [PATCH] net/socket: fix coverity issue Jens Freimann
2017-11-06 13:29 ` Peter Maydell
2017-11-06 13:48   ` Jens Freimann
2017-11-06 13:58     ` Peter Maydell
2017-11-06 13:33 ` Darren Kenny
2017-11-06 13:53   ` Jens Freimann
2017-11-13  7:13 ` Jason Wang
2017-11-13  9:51   ` Peter Maydell
2017-11-13 10:01     ` Jason Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).