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 {