From patchwork Tue Jun 12 22:12:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 365 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director8.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net (Dovecot) with LMTP id u8erAeLSIFsyWQAAIUCqbw for ; Wed, 13 Jun 2018 04:16:34 -0400 Received: from proxy2.mail.ord1d.rsapps.net ([172.30.191.6]) by director8.mail.ord1d.rsapps.net (Dovecot) with LMTP id Wx1NAeLSIFvJfwAAfY0hYg ; Wed, 13 Jun 2018 04:16:34 -0400 Received: from smtp36.gate.ord1c ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy2.mail.ord1d.rsapps.net with LMTP id ICVpAeLSIFsBMgAAfawv4w ; Wed, 13 Jun 2018 04:16:34 -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: smtp36.gate.ord1c.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; dmarc=none (p=nil; dis=none) header.from=unstable.cc X-Suspicious-Flag: YES X-Classification-ID: 151dd08a-6ee2-11e8-aebd-5452006630bd-1-1 Received: from [216.105.38.7] ([216.105.38.7:45178] helo=lists.sourceforge.net) by smtp36.gate.ord1c.rsapps.net (envelope-from ) (ecelerity 4.2.1.56364 r(Core:4.2.1.14)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id E4/D7-20087-1E2D02B5; Wed, 13 Jun 2018 04:16:33 -0400 Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1fT0wJ-00089S-TE; Wed, 13 Jun 2018 08:15:35 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1fT0wI-00089L-C4 for openvpn-devel@lists.sourceforge.net; Wed, 13 Jun 2018 08:15:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Vak2cHRsh0mLnwmfa/SN4SCoO2HHa08f7hvPQbP8G3s=; b=IR4d+g9CQrDTL144RPHvpiI+TA crSy43GE2mgUGyOUWWAEKjvii+rdESvVlO1kndsZcMoYzdMD8PwDPMPkSp/NFpHfojxPXubGWEyXi QPTBwJZb/v/2kwp5k2YvjirV3ySA0RP14MshAYQTUL9aoUEJykBAQQcczonIX4RoHYXE=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To :MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Vak2cHRsh0mLnwmfa/SN4SCoO2HHa08f7hvPQbP8G3s=; b=V1x15ygttOu9usH2BkOR0NmsdC tNeBXgGM4WxbPPLdOXCsTxa5l6fAnpC2fdsR/2EM8gA+W0Axd5h1ajXomNTVdr/xbnRsYT77Huhtv VV48Q3ZgzNXWh2oZsHJHCa14rx/d/bs3EDeGwW/dJhlDxqqXrSK+/y46ODY05r/4KDqg=; Received: from s2.neomailbox.net ([5.148.176.60]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1fT0wF-006jXB-0t for openvpn-devel@lists.sourceforge.net; Wed, 13 Jun 2018 08:15:34 +0000 From: Antonio Quartulli To: openvpn-devel@lists.sourceforge.net Date: Wed, 13 Jun 2018 16:12:15 +0800 Message-Id: <20180613081218.1834-2-a@unstable.cc> In-Reply-To: <20180613081218.1834-1-a@unstable.cc> References: <20180613081218.1834-1-a@unstable.cc> X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [5.148.176.60 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1fT0wF-006jXB-0t Subject: [Openvpn-devel] [PATCH 1/3] tun: ensure gc and argv are always freed 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: Antonio Quartulli MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox From: Antonio Quartulli Everytime a argv object is initialized with argv_new(), it has to be released with argv_reset() once not needed anymore. The same holds for gc_arena objects initialized with gc_new() that have to be released with gc_free(). Ensure both kind of objects are always properly released to avoid memory leaks. Signed-off-by: Antonio Quartulli --- src/openvpn/tun.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index 3eb0f78a..466d4d42 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -2615,6 +2615,8 @@ close_tun(struct tuntap *tt) openvpn_execve_check(&argv, NULL, 0, "OpenBSD 'destroy tun interface' failed (non-critical)"); free(tt); + argv_reset(&argv); + gc_free(&gc); } } @@ -2700,6 +2702,8 @@ close_tun(struct tuntap *tt) openvpn_execve_check(&argv, NULL, 0, "NetBSD 'destroy tun interface' failed (non-critical)"); free(tt); + argv_reset(&argv); + gc_free(&gc); } } @@ -2837,6 +2841,7 @@ close_tun(struct tuntap *tt) openvpn_execve_check(&argv, NULL, 0, "FreeBSD 'destroy tun interface' failed (non-critical)"); free(tt); + argv_reset(&argv); } } @@ -3308,6 +3313,7 @@ open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tun env_set_add( es, "ODMDIR=/etc/objrepos" ); openvpn_execve_check(&argv, es, S_FATAL, "AIX 'create tun interface' failed"); env_set_destroy(es); + argv_reset(&argv); } else { @@ -3362,6 +3368,8 @@ close_tun(struct tuntap *tt) free(tt); env_set_destroy(es); + argv_reset(&argv); + gc_free(gc); } int