[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: Jens Freimann
Subject: Re: [Qemu-devel] [PATCH] net/socket: fix coverity issue
Date: Mon, 6 Nov 2017 14:48:39 +0100
User-agent: NeoMutt/20170914 (1.9.0)

On Mon, Nov 06, 2017 at 01:29:42PM +0000, Peter Maydell wrote:
On 6 November 2017 at 13:28, Jens Freimann <address@hidden> 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 };

Do we really need the initialization here? With the two if()
conditions aligned we should be properly initializing it
in all the cases we use it, or have I missed one?

We don't need it. I added it not to have the same problem again if
the code changes in the future. I think it shouldn't hurt
because this code is only run once during initialization.
If you think it's not necessary I'm fine with removing it though.
-- PMM

reply via email to

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