From nobody Sat Apr 27 16:37:28 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509974970554317.36650217296653; Mon, 6 Nov 2017 05:29:30 -0800 (PST) Received: from localhost ([::1]:48170 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBhSj-00066C-DZ for importer@patchew.org; Mon, 06 Nov 2017 08:29:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41713) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBhRk-0005nl-BW for qemu-devel@nongnu.org; Mon, 06 Nov 2017 08:28:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBhRh-0004XS-6P for qemu-devel@nongnu.org; Mon, 06 Nov 2017 08:28:12 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51117) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eBhRg-0004X7-W1 for qemu-devel@nongnu.org; Mon, 06 Nov 2017 08:28:09 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BE72813AA2; Mon, 6 Nov 2017 13:28:07 +0000 (UTC) Received: from localhost (dhcp-192-218.str.redhat.com [10.33.192.218]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5FC8D6A045; Mon, 6 Nov 2017 13:28:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BE72813AA2 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jfreimann@redhat.com From: Jens Freimann To: qemu-devel@nongnu.org Date: Mon, 6 Nov 2017 14:28:05 +0100 Message-Id: <20171106132805.19986-1-jfreimann@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 06 Nov 2017 13:28:08 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] net/socket: fix coverity issue X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, jasowang@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Jens Freimann --- 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(NetClie= ntState *peer, const char *mcast, Error **errp) { - struct sockaddr_in saddr; + struct sockaddr_in saddr =3D { 0 }; int newfd; NetClientState *nc; NetSocketState *s; @@ -373,7 +373,7 @@ static NetSocketState *net_socket_fd_init_dgram(NetClie= ntState *peer, net_socket_read_poll(s, true); =20 /* mcast: save bound address as dst */ - if (is_connected) { + if (is_connected && mcast !=3D NULL) { s->dgram_dst =3D saddr; snprintf(nc->info_str, sizeof(nc->info_str), "socket: fd=3D%d (cloned mcast=3D%s:%d)", --=20 2.13.6