qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jens Freimann <jfreimann@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>,
	Jason Wang <jasowang@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] net/socket: fix coverity issue
Date: Mon, 6 Nov 2017 14:48:39 +0100	[thread overview]
Message-ID: <20171106134839.lu3rzudfthnfeisa@localhost.localdomain> (raw)
In-Reply-To: <CAFEAcA_nYzSr5BodQAeHr_knc4XKMwQKNT_rAmJ25RDx3ba01Q@mail.gmail.com>

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

regards,
Jens 

>thanks
>-- PMM

  reply	other threads:[~2017-11-06 13:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171106134839.lu3rzudfthnfeisa@localhost.localdomain \
    --to=jfreimann@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).