From patchwork Thu Sep 28 05:52:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steffan Karger X-Patchwork-Id: 3 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director1.mail.ord1d.rsapps.net ([172.30.157.6]) by backend31.mail.ord1d.rsapps.net (Dovecot) with LMTP id cIahBqVqzVm6FAAAgoeIoA for ; Thu, 28 Sep 2017 17:33:25 -0400 Received: from director8.mail.ord1c.rsapps.net ([172.28.130.196]) by director1.mail.ord1d.rsapps.net (Dovecot) with LMTP id PTyXGte1zFm3UwAANGzteQ ; Thu, 28 Sep 2017 17:33:25 -0400 Received: from smtp32.gate.ord1a ([172.28.255.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by director8.mail.ord1c.rsapps.net (Dovecot) with LMTP id BPB8BJ1qzVlYdQAAPBwpBw ; Thu, 28 Sep 2017 17:33:25 -0400 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-MessageSniffer-Scan-Result: 0 X-MessageSniffer-Rules: 0-298-1160-1359-w 0-298-1160-1723-w 0-298-1160-3438-w 0-298-0-11631-f X-CMAE-Scan-Result: 0 X-CNFS-Analysis: v=2.2 cv=JOh5iICb c=1 sm=1 tr=0 a=Q8DxjiC8O3VT/NpP1XjEZQ==:117 a=Q8DxjiC8O3VT/NpP1XjEZQ==:17 a=kj9zAlcOel0A:10 a=xqWC_Br6kY4A:10 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=2JCJgTwv5E4A:10 a=9hBjR9qptiMA:10 a=WiVod9pSvdkA:10 a=ZZnuYtJkoWoA:10 a=Y4BXLp1PAAAA:8 a=9sSjY8p1AAAA:8 a=P_JWiMecAAAA:8 a=FP58Ms26AAAA:8 a=I2Ojf6AKFxjgmuVx4lgA:9 a=CjuIK1q_8ugA:10 a=-FEs8UIgK8oA:10 a=NWVoK91CQyQA:10 a=byfke0vc68LhOSAAcvKj:22 a=ub54wNWiXv_DzeFsgEJW:22 a=D0-HAvA3Hk9NMREbgwuX:22 X-Orig-To: justin@openvpn.net X-Originating-Ip: [216.34.181.88] Authentication-Results: smtp32.gate.ord1a.rsapps.net; iprev=pass policy.iprev="216.34.181.88"; 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=karger-me.20150623.gappssmtp.com; dmarc=none (p=nil; dis=none) header.from=karger.me X-Classification-ID: a885ddea-a494-11e7-82bf-0024e8300ecc-1-1 Received: from [216.34.181.88] ([216.34.181.88:45136] helo=lists.sourceforge.net) by smtp32.gate.ord1a.rsapps.net (envelope-from ) (ecelerity 4.2.1.56364 r(Core:4.2.1.14)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id A4/C0-32021-4AA6DC95; Thu, 28 Sep 2017 17:33:24 -0400 Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.89) (envelope-from ) id 1dxgKL-0005xC-1O; Thu, 28 Sep 2017 21:26:37 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtps (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.89) (envelope-from ) id 1dxgKH-0005x1-05 for openvpn-devel@lists.sourceforge.net; Thu, 28 Sep 2017 21:26:33 +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; bh=2ViehPV5C4Pc1GV2ZapdePZ0UtdQtuPIoBort/Q4an8=; b=TXlWrPszuBgG5b7homlnmvYStwb5ZNxuFy5BpQVg4zd6YGanr/ETF/vsfsHOrqwVW2xh4AuZljTzaQAGpjfBheC896XaheA+S8zPnFXBdgoUlAKJd6rYugx7UGZjFqqkxC/5OLmpwEAWLk6BXeu5QXgmRkM5Pr9tiBtSO5mT4a0=; 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; bh=2ViehPV5C4Pc1GV2ZapdePZ0UtdQtuPIoBort/Q4an8=; b=cdGuU/3RAseFANl4Wkn1Fej7HGfdXQ6b4ZFv3Rk8AX4O7oCxyzYY2O9IVZ6qxCLGe0geu5N3M01y6xWq9mrLgXfYohMcqlOlum8/AcjyF5AUi2lQCGVlfYi4DbMzBWzkg6z344Eo4gIFWBxZnqsSQeWaMahLK/0+d7sNq3KtcJw=; Received-SPF: pass (sog-mx-4.v43.ch3.sourceforge.com: domain of karger.me designates 74.125.82.65 as permitted sender) client-ip=74.125.82.65; envelope-from=steffan@karger.me; helo=mail-wm0-f65.google.com; Received: from mail-wm0-f65.google.com ([74.125.82.65]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:AES128-SHA:128) (Exim 4.76) id 1dxgKE-0007Xk-BH for openvpn-devel@lists.sourceforge.net; Thu, 28 Sep 2017 21:26:32 +0000 Received: by mail-wm0-f65.google.com with SMTP id q124so2182341wmb.5 for ; Thu, 28 Sep 2017 14:26:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=karger-me.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2ViehPV5C4Pc1GV2ZapdePZ0UtdQtuPIoBort/Q4an8=; b=0zucO0wE+RtGYXWOs4DRDFNWe5Ev9x80iydzNgBXZr9DFsmOeJ23l8qWr3RY1jWhw6 zG/5Gb131jS3EoCF1YCyG2zFWCe0eTRrxOL9I414PX/GmB2OKjxhwKI4i4TwtrfmaAPB khSZGP/qehES8X5AVy268vUyWQ/HdE5/KGmuF0Q3z3rc0P1JcIse+rL546gAmy3xAwSy k8C2A1VAD/HJAP7kwof0zwWoLX7Mc9fqCOViksaQMGlUlxZqc4/sCmk1s/T8dOaBbRjW +5ADP5lwGlI5ocKO35ff9dAj32fKXBiRgf+NvfeXGyZMj8FZWBB05ZoUGdHbFk6oQCpz vAFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2ViehPV5C4Pc1GV2ZapdePZ0UtdQtuPIoBort/Q4an8=; b=P+KTDmGHki7gBC1Q8KPGOgh30NhZ3l2F2GKWc9WQ1jmi+HKSiMMyvLrtQJfftQyORX 2C4fHCSXqxxvYYOYmeuPuqQk09DfaNKs4mmx0tEF36C/IyRQ7l8Xxw250gI/IQl7g3NM h0k1UB31CE2Ni94hgMbf9dwQ5HRfUjXtyISCrEEAa08N3wRfmigINicTtMZi6ugXtV+n x/bYK5Pjeaz7D3a1+W8X2GGLtmAAhJjlr99JZsXtEYBTiN8VjuTaSHJE5isjeywdzoXK vV3SKhjoka2sKAlgb/rfU4eECAR/siJWpuNVmZFXWQ/WokNBlOvgNd2jPjpCa+c1Ny4g 4p8w== X-Gm-Message-State: AHPjjUgq8nqIz09R+F/6mXbxGUlwYF0bEFCzSqo99yt9ozCAZNOvXxmV V/TKGf3bSGuWopdgybgUZlnPwljGyLI= X-Google-Smtp-Source: AOwi7QDeVhH3RJn/BlxVzpkDkSJLqxZjVr1izYUJxnTtLlR+eRvlH+ICmIu6+3ehlukkbrs+aG3t3A== X-Received: by 10.80.153.145 with SMTP id m17mr6289035edb.265.1506613969638; Thu, 28 Sep 2017 08:52:49 -0700 (PDT) Received: from localhost.localdomain ([2001:985:e54:1050::1000]) by smtp.gmail.com with ESMTPSA id x50sm1989628edx.45.2017.09.28.08.52.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Sep 2017 08:52:48 -0700 (PDT) From: Steffan Karger To: openvpn-devel@lists.sourceforge.net Date: Thu, 28 Sep 2017 17:52:35 +0200 Message-Id: <20170928155235.32237-1-steffan@karger.me> X-Mailer: git-send-email 2.11.0 In-Reply-To: <57ab9396-0960-f915-e1d8-2c4fe0906f2d@unstable.cc> References: <57ab9396-0960-f915-e1d8-2c4fe0906f2d@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 [74.125.82.65 listed in list.dnswl.org] 0.5 RCVD_IN_SORBS_SPAM RBL: SORBS: sender is a spam source [74.125.82.65 listed in dnsbl.sorbs.net] -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-Headers-End: 1dxgKE-0007Xk-BH Subject: [Openvpn-devel] [PATCH 2/2 v3] pf: clean up temporary files if plugin init fails 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: , MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox From: Steffan Karger close_instance() tries to remove the file in c2.pf.filename, but that only works if we actually set that if we fail. So, set that filename as soon as we know we've created the file. Signed-off-by: Steffan Karger --- v2: As suggested by Antionio, get rid of local 'gc' and 'file' vars. v3: Make (struct pf_context).filename a const char * src/openvpn/pf.c | 10 ++++------ src/openvpn/pf.h | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/openvpn/pf.c b/src/openvpn/pf.c index 29231b67..1c7aeac9 100644 --- a/src/openvpn/pf.c +++ b/src/openvpn/pf.c @@ -618,19 +618,18 @@ pf_load_from_buffer_list(struct context *c, const struct buffer_list *config) void pf_init_context(struct context *c) { - struct gc_arena gc = gc_new(); #ifdef PLUGIN_PF if (plugin_defined(c->plugins, OPENVPN_PLUGIN_ENABLE_PF)) { - const char *pf_file = create_temp_file(c->options.tmp_dir, "pf", &gc); - if (pf_file) + c->c2.pf.filename = create_temp_file(c->options.tmp_dir, "pf", + &c->c2.gc); + if (c->c2.pf.filename) { - setenv_str(c->c2.es, "pf_file", pf_file); + setenv_str(c->c2.es, "pf_file", c->c2.pf.filename); if (plugin_call(c->plugins, OPENVPN_PLUGIN_ENABLE_PF, NULL, NULL, c->c2.es) == OPENVPN_PLUGIN_FUNC_SUCCESS) { event_timeout_init(&c->c2.pf.reload, 1, now); - c->c2.pf.filename = string_alloc(pf_file, &c->c2.gc); c->c2.pf.enabled = true; #ifdef ENABLE_DEBUG if (check_debug_level(D_PF_DEBUG)) @@ -659,7 +658,6 @@ pf_init_context(struct context *c) #endif } #endif - gc_free(&gc); } void diff --git a/src/openvpn/pf.h b/src/openvpn/pf.h index 414c85b8..b839fd2e 100644 --- a/src/openvpn/pf.h +++ b/src/openvpn/pf.h @@ -75,7 +75,7 @@ struct pf_context { bool enabled; struct pf_set *pfs; #ifdef PLUGIN_PF - char *filename; + const char *filename; time_t file_last_mod; unsigned int n_check_reload; struct event_timeout reload; From patchwork Thu Sep 28 05:54:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steffan Karger X-Patchwork-Id: 1 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director3.mail.ord1d.rsapps.net ([172.30.157.9]) by backend31.mail.ord1d.rsapps.net (Dovecot) with LMTP id sVV5JihkzVkNdQAAgoeIoA for ; Thu, 28 Sep 2017 17:05:44 -0400 Received: from proxy14.mail.iad3a.rsapps.net ([172.27.129.35]) by director3.mail.ord1d.rsapps.net (Dovecot) with LMTP id am63LZLWzFkEPgAAkXNnRw ; Thu, 28 Sep 2017 17:05:44 -0400 Received: from smtp39.gate.iad3a ([172.27.255.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy14.mail.iad3a.rsapps.net (Dovecot) with LMTP id Tk/NGN9jzVljMwAA1+b4IQ ; Thu, 28 Sep 2017 17:05:44 -0400 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-MessageSniffer-Scan-Result: 0 X-MessageSniffer-Rules: 0-298-1117-1334-w 0-298-1117-1698-w 0-298-0-9199-f X-CMAE-Scan-Result: 0 X-CNFS-Analysis: v=2.2 cv=RomHF2uK c=1 sm=1 tr=0 a=Q8DxjiC8O3VT/NpP1XjEZQ==:117 a=Q8DxjiC8O3VT/NpP1XjEZQ==:17 a=kj9zAlcOel0A:10 a=xqWC_Br6kY4A:10 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=2JCJgTwv5E4A:10 a=9hBjR9qptiMA:10 a=WiVod9pSvdkA:10 a=ZZnuYtJkoWoA:10 a=9sSjY8p1AAAA:8 a=P_JWiMecAAAA:8 a=FP58Ms26AAAA:8 a=m4hD85a934QHjyQe00gA:9 a=CjuIK1q_8ugA:10 a=-FEs8UIgK8oA:10 a=NWVoK91CQyQA:10 a=ub54wNWiXv_DzeFsgEJW:22 a=D0-HAvA3Hk9NMREbgwuX:22 X-Orig-To: justin@openvpn.net X-Originating-Ip: [216.34.181.88] Authentication-Results: smtp39.gate.iad3a.rsapps.net; iprev=pass policy.iprev="216.34.181.88"; 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=karger-me.20150623.gappssmtp.com; dmarc=none (p=nil; dis=none) header.from=karger.me X-Classification-ID: ca74b15a-a490-11e7-a118-782bcb681712-1-1 Received: from [216.34.181.88] ([216.34.181.88:63540] helo=lists.sourceforge.net) by smtp39.gate.iad3a.rsapps.net (envelope-from ) (ecelerity 4.2.1.56364 r(Core:4.2.1.14)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 12/28-03749-7246DC95; Thu, 28 Sep 2017 17:05:44 -0400 Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.89) (envelope-from ) id 1dxfxN-0004Bv-RY; Thu, 28 Sep 2017 21:02:53 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtps (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.89) (envelope-from ) id 1dxfxM-0004Bn-EE for openvpn-devel@lists.sourceforge.net; Thu, 28 Sep 2017 21:02:52 +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; bh=4sImXXGV08Z4CoEyBSvt53s+kuWlMDbva+LiIJFmYpw=; b=fPjUYZFSq+EDCaHmrdfSaZxCn7f6ABQgcSG3BZ1QQGwkKnLOfJffntkmribyNxoc80B7T2gzM4lv2oKdtriQWYoyaR7NsYDW9cUHu5Owr3lIon6STh5aHWke+6+/fbXlqiCdzyJJzGSp+cOF3uumiJ7+kd2RL+hh8CqkpZTdp2A=; 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; bh=4sImXXGV08Z4CoEyBSvt53s+kuWlMDbva+LiIJFmYpw=; b=fAu3X7bxxh5CFozQSdvYWBZzPq35nvRD37QT4elEjOYky5UmPEMjbONgh7Hevbz/UVCkzn8ZCyrcM0hRyp3vpM2bhHXWPwbK9GOglkawvCv3TsYeep3NAwkwcOSy32+88QtLCeA2AHpg6Bi+UB0r6xg19kH93B+XwjtM8xcCylI=; Received-SPF: pass (sog-mx-3.v43.ch3.sourceforge.com: domain of karger.me designates 74.125.82.68 as permitted sender) client-ip=74.125.82.68; envelope-from=steffan@karger.me; helo=mail-wm0-f68.google.com; Received: from mail-wm0-f68.google.com ([74.125.82.68]) by sog-mx-3.v43.ch3.sourceforge.com with esmtps (TLSv1:AES128-SHA:128) (Exim 4.76) id 1dxfxJ-0007FT-2N for openvpn-devel@lists.sourceforge.net; Thu, 28 Sep 2017 21:02:52 +0000 Received: by mail-wm0-f68.google.com with SMTP id q124so2148422wmb.5 for ; Thu, 28 Sep 2017 14:02:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=karger-me.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4sImXXGV08Z4CoEyBSvt53s+kuWlMDbva+LiIJFmYpw=; b=0vcRIDpBpVBil2X9X+lMt2HuU9GjS9GwtwzAh+Tpa2YdWCcOROL8wxpetfmCFgeelC 0RX6FXghNUKM7vyXyNLDLZ9ehooUtka6U8x0Vo9ZICisgQOsUT+Vswm8RboQtuwMZR4h ZPGINKv5yni5gjf7otBwMO7ICdeUV/TZpcjzQiovVeJlYfP2Sc7otha21GRZDifc7b2E 9bqBkscWAP/JoNljJiFtbUNg1Gs8NLMUSG8vs50d3uKTxn3gaOKM7RhJVBW6rkEUh9AT WKvZCu10r2YLdGs5DRZ1bgoSlzqnw42IxnjkJ3XDMPh7KRZ6TkzfomlTkdVBmHCpeF2Y zyeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4sImXXGV08Z4CoEyBSvt53s+kuWlMDbva+LiIJFmYpw=; b=BmQSc5JaEGbJktKR22+1hqoTLFx7G1rIgEyCVJhkFMKjmEpN0OmGELFUWaROoLgp95 D58nmxLaO1humfOEyPfjE3DZCZuKbUjm9n9S0S+gNTnOHzT/3RBIRqtQNMKbQbKkG2qX xI6Dl/nScheW5uZVTBTslHzhHXhBeCgThk7juJNlSBss+bn82Xzzas5QXbPYKAuRDcBM 4H48cFO0pmakM/GOR7d6j0oZw/5ddWWyxr9oAJcnx/wWHT/gnraHMLkdWF85NeBM1Vfy eb/zGfKBNMiDfup0PZ7ukTIXa8eTXqpDJy5akleLsXJTPsd/jaaBGDKTwI2P3dXebd36 3mkg== X-Gm-Message-State: AHPjjUi3GY327SmSxPGRNuTuUmta/31EXKk5bHJdBBJaYKPzKVQq51v8 taZCW4yR758o9tujWBRf/HOcAyb136w= X-Google-Smtp-Source: AOwi7QCVxVU5nJS9B22N7beK+VZuTwQ1cEWtWEjdupu1Ur0n/yrkKEEgJRu8tw4Nh9tXLy3dBqEAtQ== X-Received: by 10.80.240.67 with SMTP id u3mr6419546edl.35.1506614096099; Thu, 28 Sep 2017 08:54:56 -0700 (PDT) Received: from localhost.localdomain ([2001:985:e54:1050::1000]) by smtp.gmail.com with ESMTPSA id w20sm1849901edl.2.2017.09.28.08.54.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Sep 2017 08:54:55 -0700 (PDT) From: Steffan Karger To: openvpn-devel@lists.sourceforge.net Date: Thu, 28 Sep 2017 17:54:46 +0200 Message-Id: <20170928155446.32382-1-steffan@karger.me> X-Mailer: git-send-email 2.11.0 In-Reply-To: <57ab9396-0960-f915-e1d8-2c4fe0906f2d@unstable.cc> References: <57ab9396-0960-f915-e1d8-2c4fe0906f2d@unstable.cc> X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.5 RCVD_IN_SORBS_SPAM RBL: SORBS: sender is a spam source [74.125.82.68 listed in dnsbl.sorbs.net] -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [74.125.82.68 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-Headers-End: 1dxfxJ-0007FT-2N Subject: [Openvpn-devel] [PATCH 3/2] create_temp_file: prevent memory leak if gc == NULL 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: , MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox If gc == NULL, the data allocated in the alloc_gc_buf() call would never be free'd. The function is never called that way, but let's prevent future problems. Signed-off-by: Steffan Karger --- src/openvpn/misc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/openvpn/misc.c b/src/openvpn/misc.c index 90632706..86f80a6a 100644 --- a/src/openvpn/misc.c +++ b/src/openvpn/misc.c @@ -724,10 +724,13 @@ const char * create_temp_file(const char *directory, const char *prefix, struct gc_arena *gc) { static unsigned int counter; - struct buffer fname = alloc_buf_gc(256, gc); int fd; const char *retfname = NULL; unsigned int attempts = 0; + struct buffer fname = (struct buffer) { 0 }; + char buf_data[256] = { 0 }; + + buf_set_write(&fname, buf_data, sizeof(buf_data)); do {