From patchwork Sat Sep 17 12:42:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 2770 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director10.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net with LMTP id CJzaJo5NJmPWUQAAIUCqbw (envelope-from ) for ; Sat, 17 Sep 2022 18:43:26 -0400 Received: from proxy1.mail.ord1d.rsapps.net ([172.30.191.6]) by director10.mail.ord1d.rsapps.net with LMTP id qA6MJo5NJmN1SQAApN4f7A (envelope-from ) for ; Sat, 17 Sep 2022 18:43:26 -0400 Received: from smtp22.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy1.mail.ord1d.rsapps.net with LMTPS id ENqKJo5NJmO/FQAAasrz9Q (envelope-from ) for ; Sat, 17 Sep 2022 18:43:26 -0400 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp22.gate.ord1d.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dkim=fail (signature verification failed) header.d=unstable.cc; dmarc=none (p=nil; dis=none) header.from=unstable.cc X-Suspicious-Flag: YES X-Classification-ID: 24543b4c-36da-11ed-b4d3-5254001a15c2-1-1 Received: from [216.105.38.7] ([216.105.38.7:39110] helo=lists.sourceforge.net) by smtp22.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id E4/1E-15048-E8D46236; Sat, 17 Sep 2022 18:43:26 -0400 Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1oZgWQ-0003K9-FK; Sat, 17 Sep 2022 22:42:50 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1oZgWO-0003K2-5L for openvpn-devel@lists.sourceforge.net; Sat, 17 Sep 2022 22:42:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:Content-Type:MIME-Version :Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=iVYflesFwoEpd8bS2Su73cZxNJq7ZEW1XCnnA9a7p4A=; b=HxRY39EScgfLfyh6cJ9pTXznCl AzmEUcUOkCod9AEif1WcVN9CFMEHV59rifNBkuuq/qOHXla6B7k9YgDHnQFiAgpuk2muh8k7L9I5V i93AX5ZdyAlEWyNx4RGf54ydwktp8DcvU38waQdEPJPwO9zmeiF5FVCYFkIPIwMJQ82A=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=iVYflesFwoEpd8bS2Su73cZxNJq7ZEW1XCnnA9a7p4A=; b=N RUc/4ylzRnROom6D9w4PCzVWqS4kuZ5BY0jteuF/1D41nwH+gQ/diWZ6FbqWO7+djiNcj4mlpTD3P 0B8LOM1JofEoVrq+FxNVVFiSas1uRS3y/3qfx8SqEg+yfQhpOEUqsdpOgKSlA8RwfZWN7MLcc8J+1 M9p77fGklEbRztO8=; Received: from wilbur.contactoffice.com ([212.3.242.68]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1oZgWI-00BeGF-Vo for openvpn-devel@lists.sourceforge.net; Sat, 17 Sep 2022 22:42:48 +0000 Received: from smtpauth1.co-bxl (smtpauth1.co-bxl [10.2.0.15]) by wilbur.contactoffice.com (Postfix) with ESMTP id A401FD04; Sun, 18 Sep 2022 00:42:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1663454556; s=20220809-q8oc; d=unstable.cc; i=a@unstable.cc; h=From:Cc:Date:Message-Id:MIME-Version:Content-Type:Content-Transfer-Encoding; l=1677; bh=iVYflesFwoEpd8bS2Su73cZxNJq7ZEW1XCnnA9a7p4A=; b=rQU+gzfLKIHrvSDiiOcmj531CGRUZKw68D2tU8Yvf/MA4zDBiP9XHa4XPcr/GsSX Np5MIMTsvT4UxxMAWRFE9zih3mYxbmrmgmFDBYydsD5o82OzZl5UTTXkOaQxAsh/Fkc NwKLcExgb4xcTCgnVDN3Hpw+0fIPoCDURKaxnTQAfatMOoG2AOB4C2k/RZd0tKwSIYM Osq6gBVuYsxCs7aWCDq65Y3GNWmz0tVhD1PEm7QRz8MBq9tY4MKvAGnrHAn93YhtkX2 j+rfjIFFdWnqH5CX5P23GMN08T3+UD6PgiDsXcN8DZSFm4sJF2c3j8c+V2bdFo82ZW+ 6nTtXelvmQ== Received: by smtp.mailfence.com with ESMTPSA ; Sun, 18 Sep 2022 00:42:33 +0200 (CEST) From: Antonio Quartulli To: openvpn-devel@lists.sourceforge.net Date: Sun, 18 Sep 2022 00:42:27 +0200 Message-Id: <20220917224227.16988-1-a@unstable.cc> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Spam-Status: No, hits=-2.9 required=4.7 symbols=ALL_TRUSTED, BAYES_00 device=10.2.0.20 X-ContactOffice-Account: com:375058688 X-Spam-Report: Spam detection software, running on the system "util-spamd-1.v13.lw.sourceforge.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: In this case the function would exit without releasing the argv object initialized via argv_new(). Move initialization of argv after thic check is performed. While at it, also move the declaration of gc and initizlize it with gc_new(). Content analysis details: (-0.9 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [212.3.242.68 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: unstable.cc] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-Headers-End: 1oZgWI-00BeGF-Vo Subject: [Openvpn-devel] [PATCH] delete_routes(_ipv6): avoid memleak if RT_DEFINED is not set X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Camille_Gu=C3=A9rin?= , Antonio Quartulli Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox In this case the function would exit without releasing the argv object initialized via argv_new(). Move initialization of argv after thic check is performed. While at it, also move the declaration of gc and initizlize it with gc_new(). Reported-by: Camille Guérin Signed-off-by: Antonio Quartulli Acked-by: Gert Doering --- src/openvpn/route.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/openvpn/route.c b/src/openvpn/route.c index 7eaf1121..ded8fec8 100644 --- a/src/openvpn/route.c +++ b/src/openvpn/route.c @@ -2145,8 +2145,6 @@ delete_route(struct route_ipv4 *r, const struct env_set *es, openvpn_net_ctx_t *ctx) { - struct gc_arena gc; - struct argv argv = argv_new(); #if !defined(TARGET_LINUX) const char *network; #if !defined(TARGET_AIX) @@ -2165,7 +2163,8 @@ delete_route(struct route_ipv4 *r, return; } - gc_init(&gc); + struct gc_arena gc = gc_new(); + struct argv argv = argv_new(); #if !defined(TARGET_LINUX) network = print_in_addr_t(r->network, 0, &gc); @@ -2336,8 +2335,6 @@ delete_route_ipv6(const struct route_ipv6 *r6, const struct tuntap *tt, unsigned int flags, const struct env_set *es, openvpn_net_ctx_t *ctx) { - struct gc_arena gc; - struct argv argv = argv_new(); const char *network; #if !defined(TARGET_LINUX) const char *gateway; @@ -2360,7 +2357,8 @@ delete_route_ipv6(const struct route_ipv6 *r6, const struct tuntap *tt, } #endif - gc_init(&gc); + struct gc_arena gc = gc_new(); + struct argv argv = argv_new(); network = print_in6_addr( r6->network, 0, &gc); #if !defined(TARGET_LINUX)