]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
net/socket: fix coverity issue
authorJens Freimann <jfreimann@redhat.com>
Mon, 6 Nov 2017 14:05:46 +0000 (15:05 +0100)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Wed, 6 Dec 2017 15:43:29 +0000 (09:43 -0600)
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>
Signed-off-by: Jason Wang <jasowang@redhat.com>
(cherry picked from commit bb160b571fe469b03228d4502c75a18045978a74)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
net/socket.c

index 18af2ab5f3d3a8af61c8e30f421e5b3f903dca5a..6664a75aa4b9d87c134b19bb53103bc071be860d 100644 (file)
@@ -369,7 +369,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)",