From patchwork Thu Dec 10 15:47:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 1414316 X-Patchwork-Delegate: ynezz@true.cz Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=true.cz Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=qfJIzbtl; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CsJKB5LLrz9s0b for ; Fri, 11 Dec 2020 02:50:22 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=KK3YKDO3KhuMv5oDjqrb55KQZCJ+IMKagxtJu+9JYOs=; b=qfJIzbtlEW2paSRgDRPIF9tV4 d+PSq0xxFUCez060a8wcdIXJ5TFmPmtdlfsTLm8Qq8EqD1vz9vclB1XNbnB7YBzJfBoeMAcbJEm4/ 7JljZe4oLRbS+VSlL0wfd3boFxUosjufH2840Fjwv6kl72rAjeceqvMIhULxNP/YqEFezkjq0jYQI fkqujo1azBej0sfaqQmK+rTQ8do839m7kjpYfdu9jJ9KljA3C7GviP+8b4uWV1JnJRk38SbS6aVkP XxJ3som2nZrNwTEbyArktKqGGNE0bJp+GxeopLsTG5kgPOHwah1A7+Kqp4d5KnWspXl4eKTn2FZzi RGZFDxFBg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1knOBV-0002Bh-Nf; Thu, 10 Dec 2020 15:48:49 +0000 Received: from smtp-out.xnet.cz ([178.217.244.18]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1knOAr-0001t9-Fm for openwrt-devel@lists.openwrt.org; Thu, 10 Dec 2020 15:48:13 +0000 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id 37F7218F49; Thu, 10 Dec 2020 16:48:08 +0100 (CET) Received: by meh.true.cz (OpenSMTPD) with ESMTP id 81b0a78d; Thu, 10 Dec 2020 16:47:50 +0100 (CET) From: =?utf-8?q?Petr_=C5=A0tetiar?= To: openwrt-devel@lists.openwrt.org Subject: [PATCH uclient 10/12] uclient-fetch: init_ca_cert: fix memory leak Date: Thu, 10 Dec 2020 16:47:57 +0100 Message-Id: <20201210154759.1114-11-ynezz@true.cz> In-Reply-To: <20201210154759.1114-1-ynezz@true.cz> References: <20201210154759.1114-1-ynezz@true.cz> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201210_104809_740489_CAD34A3C X-CRM114-Status: GOOD ( 16.10 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 NUMERIC_HTTP_ADDR URI: Uses a numeric IP address in URL 0.0 WEIRD_PORT URI: Uses non-standard port number for HTTP X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Petr_=C5=A0tetiar?= Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Fixes following memory leak: $ valgrind --quiet --leak-check=full uclient-fetch -q http://127.0.0.1:1922/does-not-exist 51 (16 direct, 35 indirect) bytes in 1 blocks are definitely lost in loss record 4 of 9 at 0x4C31A3F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x4C33D84: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x553C7DF: glob_in_dir (glob.c:1410) by 0x553D5E8: glob@@GLIBC_2.27 (glob.c:1097) by 0x401D62: init_ca_cert (uclient-fetch.c:503) by 0x401D62: main (uclient-fetch.c:741) Signed-off-by: Petr Štetiar --- uclient-fetch.c | 1 + 1 file changed, 1 insertion(+) diff --git a/uclient-fetch.c b/uclient-fetch.c index 1c66ac6d33ae..bbf5eec58d71 100644 --- a/uclient-fetch.c +++ b/uclient-fetch.c @@ -503,6 +503,7 @@ static void init_ca_cert(void) glob("/etc/ssl/certs/*.crt", 0, NULL, &gl); for (i = 0; i < gl.gl_pathc; i++) ssl_ops->context_add_ca_crt_file(ssl_ctx, gl.gl_pathv[i]); + globfree(&gl); } static void init_ustream_ssl(void)