From patchwork Wed Aug 29 03:49:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steffan Karger X-Patchwork-Id: 455 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director9.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net (Dovecot) with LMTP id +477BM+khltnHAAAIUCqbw for ; Wed, 29 Aug 2018 09:51:11 -0400 Received: from proxy8.mail.ord1d.rsapps.net ([172.30.191.6]) by director9.mail.ord1d.rsapps.net with LMTP id sFnxBM+khlttAwAAalYnBA ; Wed, 29 Aug 2018 09:51:11 -0400 Received: from smtp33.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy8.mail.ord1d.rsapps.net with LMTP id OHNzBM+khlv+eAAAGdz6CA ; Wed, 29 Aug 2018 09:51:11 -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: smtp33.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; dmarc=none (p=nil; dis=none) header.from=fox-it.com X-Suspicious-Flag: YES X-Classification-ID: 95c3a84e-ab92-11e8-9646-525400041ef2-1-1 Received: from [216.105.38.7] ([216.105.38.7:46958] helo=lists.sourceforge.net) by smtp33.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id EA/AD-06674-EC4A68B5; Wed, 29 Aug 2018 09:51:10 -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 1fv0rU-0004qI-5b; Wed, 29 Aug 2018 13:50:20 +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 1fv0rT-0004qC-7Z for openvpn-devel@lists.sourceforge.net; Wed, 29 Aug 2018 13:50:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:MIME-Version:Message-ID:Date:Subject: CC:To:From:Sender:Reply-To:Content-Transfer-Encoding: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=T6j03csTfgR6tb+mGATXe/VCZDkEJCk44Ya3OwAbGBE=; b=TbR57cmhXRYkSHw40KB9hp7Lou cRmZ78j/qehratUkkZWR3kn4gi3qHxTJ5gP29j3vHADE2yPG0ZGH3xd13O84y8ibX7Uqo1PCWP73V xANNysd38X6qiSEu8DHXghjvu5zGg3igVlmh3conetQeb6lBwhejGhj+2yL/lUraVVZE=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From:Sender: Reply-To:Content-Transfer-Encoding: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=T6j03csTfgR6tb+mGATXe/VCZDkEJCk44Ya3OwAbGBE=; b=W TpZenAaJavt7bh1rF6ueGM35/14grVOLDveU6kADpQ5641I2mK7pu9e2v7vsunTP1iaOvckk3Dowp eHLkwhhIpEFDMJjEJm1vlPuHWhxChOpWxGf3SK3MoIXcYW3AbSNds7IToS1K/0H7ReqGZvxTBbLQG tqhmeb7sgbaYj49Q=; Received: from ns2.fox-it.com ([178.250.144.131]) by sfi-mx-4.v28.lw.sourceforge.com with esmtps (TLSv1:ECDHE-RSA-AES256-SHA:256) (Exim 4.90_1) id 1fv0rR-0024pe-PP for openvpn-devel@lists.sourceforge.net; Wed, 29 Aug 2018 13:50:19 +0000 Received: from FOXDFT52.FOX.local (unknown [10.0.0.129]) by ns2.fox-it.com (Postfix) with ESMTPS id 88B401AF889 for ; Wed, 29 Aug 2018 15:50:10 +0200 (CEST) Received: from steffan-fox.fox.local (172.16.5.175) by FOXDFT52.FOX.local (10.0.0.129) with Microsoft SMTP Server (TLS) id 15.0.1293.2; Wed, 29 Aug 2018 15:50:10 +0200 From: Steffan Karger To: Date: Wed, 29 Aug 2018 15:49:43 +0200 Message-ID: <1535550583-21825-1-git-send-email-steffan.karger@fox-it.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-ClientProxiedBy: FOXDFT52.FOX.local (10.0.0.129) To FOXDFT52.FOX.local (10.0.0.129) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 SPF_PASS SPF: sender matches SPF record X-Headers-End: 1fv0rR-0024pe-PP Subject: [Openvpn-devel] [PATCH] Fix memory leak after sighup 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: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox The c.es env_set is (re)allocated for each "sighup loop iteration", while it was free'd only once at process shutdown. Move the env_set_destroy() call to match the same level as the env_set_create() call to fix that. Signed-off-by: Steffan Karger Acked-by: Arne Schwabe --- src/openvpn/openvpn.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/openvpn/openvpn.c b/src/openvpn/openvpn.c index b9e914a..3819889 100644 --- a/src/openvpn/openvpn.c +++ b/src/openvpn/openvpn.c @@ -329,6 +329,7 @@ openvpn_main(int argc, char *argv[]) } while (c.sig->signal_received == SIGUSR1); + env_set_destroy(c.es); uninit_options(&c.options); gc_reset(&c.gc); } @@ -337,8 +338,6 @@ openvpn_main(int argc, char *argv[]) context_gc_free(&c); - env_set_destroy(c.es); - #ifdef ENABLE_MANAGEMENT /* close management interface */ close_management();