From patchwork Mon Oct 29 17:05:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 17596 X-Patchwork-Delegate: sw@simonwunderlich.de Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from open-mesh.org (localhost [IPv6:::1]) by open-mesh.org (Postfix) with ESMTP id CBFB88232A; Mon, 29 Oct 2018 18:05:51 +0100 (CET) Authentication-Results: open-mesh.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=narfation.org header.i=@narfation.org header.b="Hh/tjmeq"; dkim-atps=neutral Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2001:4d88:2000:7::2; helo=v3-1039.vlinux.de; envelope-from=sven@narfation.org; receiver= Received: from v3-1039.vlinux.de (narfation.org [IPv6:2001:4d88:2000:7::2]) by open-mesh.org (Postfix) with ESMTPS id BC27B801C8 for ; Mon, 29 Oct 2018 18:05:49 +0100 (CET) Received: from sven-desktop.home.narfation.org (p200300C593CA0DFD89F7157A061A7EA0.dip0.t-ipconnect.de [IPv6:2003:c5:93ca:dfd:89f7:157a:61a:7ea0]) by v3-1039.vlinux.de (Postfix) with ESMTPSA id 47DC21100E7; Mon, 29 Oct 2018 18:05:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=narfation.org; s=20121; t=1540832749; bh=aSCdZwHaXTNGG3VWKIX08t9JqlybwUQG8DlkFNyMeXk=; h=From:To:Cc:Subject:Date:From; b=Hh/tjmeqnoOGTE0Ep9iD+i6b3HzLcc7IMx6Y4y0sHfV/M5H7TYAYgvIFBQ1IWE05A A6ignOmal6HgwqiwDJMo66HAa6wWUKzwk2h0MxnerUJVr0POUzlceQx9dz31m9NA1K vJ5wNwRHnU5ggfK7DbgIzbMzYq2DgR2iOe/AlMCg= From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Date: Mon, 29 Oct 2018 18:05:42 +0100 Message-Id: <20181029170542.5406-1-sven@narfation.org> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Subject: [B.A.T.M.A.N.] [PATCH maint] alfred: Fix detection of own packets for IPv4 mode X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking Cc: Jonathan Haws Errors-To: b.a.t.m.a.n-bounces@lists.open-mesh.org Sender: "B.A.T.M.A.N" The incoming packet address is checked for a match against the local interface addresses to avoid processing its own packets. The IPv4 implementation used the same code but only initialized 4 of the 16 bytes of the address in the recv function. The interface initialization code in netsock_set_interfaces set all unused bytes to zero but recv_alfred_packet was modified to use 12 random bytes from the stack. Both functions must work the same way and first set the address bytes to zero and overwrite the actual used bytes with the address bytes. Otherwise, the result of netsock_set_interfaces for own packets is random in the IPv4 implementation. Fixes: c7da798113a2 ("alfred: IPv4 multicast distribution support.") Signed-off-by: Sven Eckelmann --- Cc: Jonathan Haws --- recv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/recv.c b/recv.c index 59d759c..5ff4bb5 100644 --- a/recv.c +++ b/recv.c @@ -416,6 +416,7 @@ int recv_alfred_packet(struct globals *globals, struct interface *interface, packet = (struct alfred_tlv *)buf; + memset(&alfred_source, 0, sizeof(alfred_source)); if (globals->ipv4mode) { memcpy(&alfred_source, &source4.sin_addr, sizeof(source4.sin_addr)); } else {