From nobody Mon May 6 05:44:11 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 1510250615078556.5849340216353; Thu, 9 Nov 2017 10:03:35 -0800 (PST) Received: from localhost ([::1]:38195 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCrAe-0005u1-Ll for importer@patchew.org; Thu, 09 Nov 2017 13:03:20 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57199) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCr9E-0005J3-A5 for qemu-devel@nongnu.org; Thu, 09 Nov 2017 13:01:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eCr98-0002L0-FG for qemu-devel@nongnu.org; Thu, 09 Nov 2017 13:01:52 -0500 Received: from hera.aquilenet.fr ([141.255.128.1]:58938) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eCr98-0002KQ-91 for qemu-devel@nongnu.org; Thu, 09 Nov 2017 13:01:46 -0500 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id A4380F690; Thu, 9 Nov 2017 19:01:46 +0100 (CET) Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BpLIM72T0azL; Thu, 9 Nov 2017 19:01:45 +0100 (CET) Received: from var.youpi.perso.aquilenet.fr (unknown [81.18.188.212]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 1327AFCDA; Thu, 9 Nov 2017 19:01:45 +0100 (CET) Received: from samy by var.youpi.perso.aquilenet.fr with local (Exim 4.89) (envelope-from ) id 1eCr94-0003dJ-Dq; Thu, 09 Nov 2017 19:01:42 +0100 X-Virus-Scanned: Debian amavisd-new at aquilenet.fr From: Samuel Thibault To: qemu-devel@nongnu.org Date: Thu, 9 Nov 2017 19:01:42 +0100 Message-Id: <20171109180142.13923-2-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171109180142.13923-1-samuel.thibault@ens-lyon.org> References: <20171109180142.13923-1-samuel.thibault@ens-lyon.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 141.255.128.1 Subject: [Qemu-devel] [PULL 1/1] slirp: don't zero the whole ti_i when m == NULL 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: jan.kiszka@siemens.com, Samuel Thibault , stefanha@redhat.com, Tao Wu 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" From: Tao Wu 98c63057d2144fb81681580cd84c13c93794c96e ('slirp: Factorizing tcpiphdr structure with an union') introduced a memset call to clear possibly-undefined fields in ti. This however overwrites src/dst/pr which are used below. So let us clear only the unused fields. This should fix some rare cases (some RST cases, keep alive probes) where packets would be sent to 0.0.0.0. Signed-off-by: Tao Wu Signed-off-by: Samuel Thibault --- slirp/tcp_subr.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c index dc8b4bbb50..da0d53743f 100644 --- a/slirp/tcp_subr.c +++ b/slirp/tcp_subr.c @@ -148,7 +148,16 @@ tcp_respond(struct tcpcb *tp, struct tcpiphdr *ti, str= uct mbuf *m, m->m_data +=3D IF_MAXLINKHDR; *mtod(m, struct tcpiphdr *) =3D *ti; ti =3D mtod(m, struct tcpiphdr *); - memset(&ti->ti, 0, sizeof(ti->ti)); + switch (af) { + case AF_INET: + ti->ti.ti_i4.ih_x1 =3D 0; + break; + case AF_INET6: + ti->ti.ti_i6.ih_x1 =3D 0; + break; + default: + g_assert_not_reached(); + } flags =3D TH_ACK; } else { /* --=20 2.14.2