[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] net/socket: fix coverity issue

From: Jason Wang
Subject: Re: [Qemu-devel] [PATCH] net/socket: fix coverity issue
Date: Mon, 13 Nov 2017 18:01:24 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0

On 2017年11月13日 17:51, Peter Maydell wrote:
On 13 November 2017 at 07:13, Jason Wang <address@hidden> wrote:

On 2017年11月06日 21:28, Jens Freimann wrote:
This fixes coverity issue CID1005339.

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

Cc: address@hidden
Reported-by: Peter Maydell <address@hidden>
Signed-off-by: Jens Freimann <address@hidden>
   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)",

Applied, thanks.
Er, this version didn't pass code review and you should
apply v2 instead...

-- PMM

Oops, indeed.

Apply V2.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]