From patchwork Fri Oct 11 05:32:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13832060 Received: from fhigh-a7-smtp.messagingengine.com (fhigh-a7-smtp.messagingengine.com [103.168.172.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 131FE17BD6 for ; Fri, 11 Oct 2024 05:32:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.158 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624734; cv=none; b=MDnHFux4qLpICRJFG9zh2vcM8tjv5WITH7JJP7cT9oO63JIzXS53+WUB9YPsInQIB8vguCGxKhBfcARmU/udpTUeCX8nkaDgE+XH4a0XduHdGtNoCDFlPfaBsw5I8rxKJVzF4uDzJmqvfUEsVmjdUeiXceSHjqN4QT/1nO41ygk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624734; c=relaxed/simple; bh=CoJ2mCqCsDhqTX77JbU82WTpZp5AGg4GnXaS8kaoX3M=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=WKW9qIkQuf6zDAP8lXHNOFBbcW7UYAes7CjjwBcKB8c7bZeSmg3xVgXIb0am9VFCf/sSR3oAyUxaUeh1H4S13jZLS/UlvBzxGm6AvCaz8AjmjYgWhYCEvGC6Q5baUtSJ46ZueeuquV2nDLHtuIqdunS4hGnvtJ8TD9vrMMoMgB8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=rQsftpTN; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=l3f7tNGD; arc=none smtp.client-ip=103.168.172.158 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="rQsftpTN"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="l3f7tNGD" Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfhigh.phl.internal (Postfix) with ESMTP id F0DFE1140129 for ; Fri, 11 Oct 2024 01:32:10 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Fri, 11 Oct 2024 01:32:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1728624730; x=1728711130; bh=LfN4uR3CFj 1a3laAMQ6GnUG1jKazvozZPwi4Ios1feQ=; b=rQsftpTNy+ZUGQ/0xUH6WlZfJE 82iXKIAU+q9e3x00wWCuCSuvdiRbA/cYerOS+YYQvNukTjmRspC5m3aC4+ddmST9 GyTR8y8RUkNfiWu3+UikM5ZdDO8KlUjTgruG8jW4ZglSsxW+xgRm0peXps7Vc4rg AXTH53QdVX8eG5UP7vF4zRtamrGQKG+nNvA67JGSBjtJ4pm3IqXByoC2TbmB+Foa OBL5FWdPs+iiM2BkKWT3GKvIehWKnBmWQu/GJDKElhBZG+AMDlvDg6M3NLIuG0fn C6TWqvJJEFdjGdTPNCSt/+O8DEcXbzBo6oaoPP+x8eXGS8frY3HJ3Vx21QXw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1728624730; x=1728711130; bh=LfN4uR3CFj1a3laAMQ6GnUG1jKaz vozZPwi4Ios1feQ=; b=l3f7tNGDA+hWGeIwM/KrEGoMFd8O16oJJX2/COB5nvoa YFc9PtK8ciOO2lp+ijaQiU/WuzL7xvGOUPPsCI7Kk2qvHRSbHh+rIqJuTV8qe+Mb qS3Ga0UoUKscDbYXSRopluLAa34I7u6N/naUdg3afVWjD1TPDr3k5KDE+/j/0DeX 67k/susvRFJrd2/WTJ8Gaaesown6jl0oxrMa7jicYYsN87sJJBVXsa4Fk9TM+2H/ ZprMzTNp0f5TF3v0O/T0dArMr2U13MyHm2KvsoC7t69wb09M8EWLLRx6Y1CzbfsN 5CYBuShv7k9msVRYpl7LySYn4pjWzbVbNhIdN0198w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdefjedgleelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuf fkfhggtggujgesthdtredttddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhh rghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnhepheekfeefgeegvd egvdeffeehtedttdffjeeuffelgffgheefleffleejvdefheeinecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimhdpnhgspg hrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepghhithesvhhg vghrrdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Fri, 11 Oct 2024 01:32:10 -0400 (EDT) Received: by vm-mail (OpenSMTPD) with ESMTPSA id e47e6ce6 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Fri, 11 Oct 2024 05:31:04 +0000 (UTC) Date: Fri, 11 Oct 2024 07:32:08 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 01/21] builtin/ls-remote: plug leaking server options Message-ID: <89b66411354437a1e3a97751f185889dffb84126.1728624670.git.ps@pks.im> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: The server options populated via `OPT_STRING_LIST()` is never cleared, causing a memory leak. Plug it. This leak is exposed by t5702, but plugging it alone does not make the whole test suite pass. Signed-off-by: Patrick Steinhardt --- builtin/ls-remote.c | 1 + 1 file changed, 1 insertion(+) diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c index f723b3bf3bb..f333821b994 100644 --- a/builtin/ls-remote.c +++ b/builtin/ls-remote.c @@ -166,6 +166,7 @@ int cmd_ls_remote(int argc, status = 0; /* we found something */ } + string_list_clear(&server_options, 0); ref_sorting_release(sorting); ref_array_clear(&ref_array); if (transport_disconnect(transport)) From patchwork Fri Oct 11 05:32:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13832061 Received: from fhigh-a7-smtp.messagingengine.com (fhigh-a7-smtp.messagingengine.com [103.168.172.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1019617BD6 for ; Fri, 11 Oct 2024 05:32:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.158 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624739; cv=none; b=FE9awuhRZtsOrcHMV6Qf9SsPHGh259NUaujN7pnK93wAF6WUTrjYpjF9PLbJPVklh2xS9uwHT8OYVcnkk+IuMSyVAtwxlvzzflZHKyksSdYM3sHg1JPQfdCkwTAW2akbaGG5xWOVSdr7P5pEHzDgPxEFKkgu/QA2JddstpipCFI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624739; c=relaxed/simple; bh=fydoxPwjhJ+k+VtyhOJCFs7cZMyh6z7GSwVga/bf0hw=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=RTNZFCpO3kogWs+lfu3xs45D4ivFSh294/aWzaykxxZ7jVBC1p7XiYz4oNl5FqpFatfPVJK7eoMgwG5jMhpF+VkCpkKU6aQ50j3MCPYfYS+Lq1d1ZpBK9nSGKtL0yfMeqOx+xWsbigciNwqjhOO98aHwW9IyNnKO1YTi3smvAtw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=j93oCPKB; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=D33R3/MK; arc=none smtp.client-ip=103.168.172.158 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="j93oCPKB"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="D33R3/MK" Received: from phl-compute-08.internal (phl-compute-08.phl.internal [10.202.2.48]) by mailfhigh.phl.internal (Postfix) with ESMTP id 13C84114012D for ; Fri, 11 Oct 2024 01:32:16 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-08.internal (MEProxy); Fri, 11 Oct 2024 01:32:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1728624736; x=1728711136; bh=VrAZbGW7E9 9kZwLB2Evv4uDBAw/sW+wiqL1oah4mDIQ=; b=j93oCPKBF7H6mSnGnySPTlX+g9 9gRmS4vY/4dYHdTB6zigX47TEWoGlrEIPAK9DuBeaCb2lZYjMNP3ncIkVK04dO4X zqxwMl7CySDry9B/SVGKYDOXcGMB890zjyJi6pK7KmXuYhlWMvJhhj7Ldph29iFq mvnlllEJsA8einf2UzhJrnPpMxh71Thi+T1pzF1KEp4d5Zxs0UM1A4IxM3859Lld aAvXN/7Icw0LJIvmoWW/sS/f93ik3e2vaqdaEBNYqVXbvWmLejzPrlwnoq/Sp0j3 qEvXFOctxLCfEvdweV+Tz0lQyxyjePchWfliBsDWpgQnrXal+NRgL3XK5AGg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1728624736; x=1728711136; bh=VrAZbGW7E99kZwLB2Evv4uDBAw/s W+wiqL1oah4mDIQ=; b=D33R3/MKvsw2HJ7EZt6HdSe8mrOv9TuU1Vkfwwtb65LY qU1ELtQLLxTpVX3nQY8DC3XW5R/QY7Q4AsI/bVwLgbPlQsr92HEwtf3K18D7MJLy 3y6X0jvVqzcCHFmHthZPcMygYK8DTASCa8mZQKa6tIG/2Y7gZkpWuMJ7OlsKUpMD bmJGl4P3c5XhxcQButWxN+5KgjN8nwcSDhSjtxT/f/8mXPeH8fZhKGauxCh6hruu sbUbAojKrr8nlupZ0D4JGmlDT4ErTm/Ur6lrQxsaAqDAdqUDlIQOTzReBn++xUpA aiYMF1I/ILVr9TUvxvcGn5mscF78M7U9+ZlY01UL1g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdefjedgleelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuf fkfhggtggujgesthdtredttddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhh rghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnhepheekfeefgeegvd egvdeffeehtedttdffjeeuffelgffgheefleffleejvdefheeinecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimhdpnhgspg hrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepghhithesvhhg vghrrdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Fri, 11 Oct 2024 01:32:15 -0400 (EDT) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 5674dc25 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Fri, 11 Oct 2024 05:31:08 +0000 (UTC) Date: Fri, 11 Oct 2024 07:32:13 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 02/21] t/helper: fix leaks in "reach" test tool Message-ID: <1c42e194b20637ef84c61b62e29fdd9047b1acfb.1728624670.git.ps@pks.im> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: The "reach" test tool doesn't bother to clean up any of its allocated resources, causing various leaks. Plug them. Signed-off-by: Patrick Steinhardt --- t/helper/test-reach.c | 10 ++++++++++ t/t6600-test-reach.sh | 1 + 2 files changed, 11 insertions(+) diff --git a/t/helper/test-reach.c b/t/helper/test-reach.c index 995e382863a..84deee604ad 100644 --- a/t/helper/test-reach.c +++ b/t/helper/test-reach.c @@ -127,10 +127,12 @@ int cmd__reach(int ac, const char **av) exit(128); printf("%s(A,X):\n", av[1]); print_sorted_commit_ids(list); + free_commit_list(list); } else if (!strcmp(av[1], "reduce_heads")) { struct commit_list *list = reduce_heads(X); printf("%s(X):\n", av[1]); print_sorted_commit_ids(list); + free_commit_list(list); } else if (!strcmp(av[1], "can_all_from_reach")) { printf("%s(X,Y):%d\n", av[1], can_all_from_reach(X, Y, 1)); } else if (!strcmp(av[1], "can_all_from_reach_with_flag")) { @@ -153,6 +155,7 @@ int cmd__reach(int ac, const char **av) filter.with_commit_tag_algo = 0; printf("%s(_,A,X,_):%d\n", av[1], commit_contains(&filter, A, X, &cache)); + clear_contains_cache(&cache); } else if (!strcmp(av[1], "get_reachable_subset")) { const int reachable_flag = 1; int i, count = 0; @@ -176,7 +179,14 @@ int cmd__reach(int ac, const char **av) die(_("too many commits marked reachable")); print_sorted_commit_ids(list); + free_commit_list(list); } + object_array_clear(&X_obj); + strbuf_release(&buf); + free_commit_list(X); + free_commit_list(Y); + free(X_array); + free(Y_array); return 0; } diff --git a/t/t6600-test-reach.sh b/t/t6600-test-reach.sh index 2591f8b8b39..307deefed2c 100755 --- a/t/t6600-test-reach.sh +++ b/t/t6600-test-reach.sh @@ -2,6 +2,7 @@ test_description='basic commit reachability tests' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh # Construct a grid-like commit graph with points (x,y) From patchwork Fri Oct 11 05:32:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13832062 Received: from fhigh-a7-smtp.messagingengine.com (fhigh-a7-smtp.messagingengine.com [103.168.172.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4FA21FCC73 for ; Fri, 11 Oct 2024 05:32:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.158 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624741; cv=none; b=Iin6ZwCeGnE5JjzZBbBNVM36Ms49z2a/orKqp+klePrBC2oqTLbTp0fhWDVhS9XVt8RTXPx6U83wWCdmyv2ZbdzWng/9FX3ok0F65TLHVQURKPHBValqWE+u3VzS1n43wJBG8Gq7gHPVLci6xyIPI3oBiI0X2H8KF574PLRD5co= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624741; c=relaxed/simple; bh=2ohlIo6gTE782gMCTf6Wfx2vydD8u3XotEyjzhTMUkc=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=JcGfSsgpzEreI4MjnyrKnmIimwNdjiBcBlyM5/bhvxlyzVEffg0ZsIpkGg/4cMU6M0aMCm/K9j/MpKYjp8Xt4hZRvBwNP3fuyIlio0/X3EFsGipL2P/XaRCMjHGyrKxKX7mOYU/c2fKj5GQQlFH1BPdJ/Y5DSg2iLPYSXIJIuHo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=iVLZMg0M; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=NbcPwu+O; arc=none smtp.client-ip=103.168.172.158 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="iVLZMg0M"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="NbcPwu+O" Received: from phl-compute-08.internal (phl-compute-08.phl.internal [10.202.2.48]) by mailfhigh.phl.internal (Postfix) with ESMTP id E4D2A1140126 for ; Fri, 11 Oct 2024 01:32:18 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-08.internal (MEProxy); Fri, 11 Oct 2024 01:32:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1728624738; x=1728711138; bh=w4odnqwsmr cJhwpfwJ5mx0IT0bPqbKXUKz0Wdy27sQ0=; b=iVLZMg0MOd/6T9DJuIMYEGqdLT vs/YtTkyUEinM7YYfp+MQrePtkP0SrfgnWZYE4x0/nV2ikY3Tw6BtL5irecu+xyc ZYwVTUXBi05+hn+/QG4Smh1kKcfd+lh9rtYIs1AdDeI71TkxyftH3cHyEw1ouZhw u3bfjqcdjMf3l7Y1rfJOYlnZI9h6lS+j26HXUAXATE1U6d+ArVULt/YGd2n7myg2 GKU47ZBvbb3TYKtek6HEl5jRN/uh4jBlRliPMFbUdGGGwnOgC0QzHHif/twl7Ahl LkIXWsnvqMlvOKbYfjEoL0w5xruZh5Ge+h87pBP1ZhbO+d8R23Tp/BDlC0iQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1728624738; x=1728711138; bh=w4odnqwsmrcJhwpfwJ5mx0IT0bPq bKXUKz0Wdy27sQ0=; b=NbcPwu+OtLtceXXzM0fqizXOnnz0yC82LJWvPQZtwwuU QCgAcAguMXwyaDP1B6jM8NkGpSCdTtKd7bL26ONivXq8auGKp116YOE/SKXJGOtf XITNxeBynxeHP+16XQdw0J/Y3fz+gaVGT6K+8wYQW+Y1ZGApnBY2DUYq3q7s0LnC OHZIIf4xNpzdlpHcvroxP+PDNKpZc9V/12SYf5Xn1aV3dtCr7I7+keHng1mm29/i HV4op3qCBXGmkz86K1441ylBUkdJk6NtTS38lGScb2BufyH2yZw0kYw7p+cyR5Qr fjomHCOHqiaWYWO4CQIIFmQN3hmvxXgIQptbV4q6vw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdefjedgleelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuf fkfhggtggujgesthdtredttddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhh rghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnhepheekfeefgeegvd egvdeffeehtedttdffjeeuffelgffgheefleffleejvdefheeinecuvehluhhsthgvrhfu ihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimhdpnhgspg hrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepghhithesvhhg vghrrdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Fri, 11 Oct 2024 01:32:18 -0400 (EDT) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 8c38ae81 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Fri, 11 Oct 2024 05:31:11 +0000 (UTC) Date: Fri, 11 Oct 2024 07:32:16 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 03/21] grep: fix leak in `grep_splice_or()` Message-ID: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: In `grep_splice_or()` we search for the next `TRUE` node in our tree of grep exrpessions and replace it with the given new expression. But we don't free the old node, which causes a memory leak. Plug it. This leak is exposed by t7810, but plugging it alone isn't sufficient to make the test suite pass. Signed-off-by: Patrick Steinhardt --- grep.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grep.c b/grep.c index 701e58de04e..e9337f32cbf 100644 --- a/grep.c +++ b/grep.c @@ -756,6 +756,7 @@ static struct grep_expr *grep_splice_or(struct grep_expr *x, struct grep_expr *y assert(x->node == GREP_NODE_OR); if (x->u.binary.right && x->u.binary.right->node == GREP_NODE_TRUE) { + free(x->u.binary.right); x->u.binary.right = y; break; } From patchwork Fri Oct 11 05:32:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13832063 Received: from fhigh-a7-smtp.messagingengine.com (fhigh-a7-smtp.messagingengine.com [103.168.172.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 876A217BD6 for ; Fri, 11 Oct 2024 05:32:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.158 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624743; cv=none; b=VLTMZ2rW0ZlrpeJkIGOeCR070Yn6ORZ7XyZ13FTBtlB6gdzlAN8LCGMk79lMv6OxfimuUlIlPK+UzGdAw+YOh+5xP4TovcWSay5JSxaFZGzrZ5LntS6I8O9F+RMxYieit8HmLeF/RFE81DlMtOMG2gobJAuCZoFzMlNcIECR8LQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624743; c=relaxed/simple; bh=zXYo0bP6TUYHKWjUrPQX85daV5BOVv3KsxGkwigzfUM=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=SS94pjgxLnMk+IELqPvBeKkEYrN15UpAO82IOoX3l2As2MKkz9UwnX28IGG+oz97lOdUqLHK2J90oy6vtEWyA3gBocU3kvp7MPGrh1rTkRrCawH2ecs3w+f5tDsTjAtAWSxf00ZjdJB21z6lTc+nKn0H6D7fKomnGn22pnwty4k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=e84HxLie; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=bS0wBcKg; arc=none smtp.client-ip=103.168.172.158 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="e84HxLie"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="bS0wBcKg" Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfhigh.phl.internal (Postfix) with ESMTP id BC6291140129 for ; Fri, 11 Oct 2024 01:32:20 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-01.internal (MEProxy); Fri, 11 Oct 2024 01:32:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1728624740; x=1728711140; bh=lDcg1vIXRA GMfVCNOw/s+H2p9E4G0J5mgeuYCl4vsp0=; b=e84HxLieazY7973Ok4M5/EoBa0 WDXxlVyFsjAL+3LwAv3XUum0eWn/0FHoi4GdwFNFRmaOhygOKF8px3QP5n0wGzhf adpZkVEXtJ3fvUh7OVr+vrFxuwt2OYgB10WeDliS59ORQQE98oupxJexRTkUGMYe +DTrySXx/yK6YedqbhfuyXBmpEGghwXP1nxWG7JcljyhJrVIotKYcz/okBioD52E 3/BYtq56dlecDNtk93ySniRYVS5k+28hK8euKfV13Fde865hgNwsm4e7ysF24gOD AB10L5piMJGDZFfLPxqaX/5wiwAED99XiOrClcxU7gMlSKuH4BjszmSKz/TA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1728624740; x=1728711140; bh=lDcg1vIXRAGMfVCNOw/s+H2p9E4G 0J5mgeuYCl4vsp0=; b=bS0wBcKga9h0zc0Nh6dTRij2HxI9AxVHckYYqEQuyC0R Mn+1RSjdg9J17H1YeCgRvYBRiIVmW/wFh+sMJNlFNQyTFJ9LqsRWiORtVPfIKT5o u6IxNdW0NSF45xoHR8tbX6ClrxcQH3nf1WX3YVX7TuBbJxthhgJoH1npdo5nWLKx REfI60OUl7OzM1ZlCmXEQKU9jWgD43iUohPvmdSW0CjQtG4MPPWmzFVG5JdYtIeE 8Jrsy7Hwh+oHdIABW/lXu0K7xrQYLqzinNe+XHnu5LbkEI/q0TmBb1beZ5dpUed9 gm/V9PhsiGo504eGYB0U3Q30s8QayLogdeZ7v1XR6Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdefjedgleelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuf fkfhggtggujgesthdtredttddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhh rghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnhepheekfeefgeegvd egvdeffeehtedttdffjeeuffelgffgheefleffleejvdefheeinecuvehluhhsthgvrhfu ihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimhdpnhgspg hrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepghhithesvhhg vghrrdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Fri, 11 Oct 2024 01:32:20 -0400 (EDT) Received: by vm-mail (OpenSMTPD) with ESMTPSA id fac8859b (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Fri, 11 Oct 2024 05:31:14 +0000 (UTC) Date: Fri, 11 Oct 2024 07:32:18 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 04/21] builtin/grep: fix leak with `--max-count=0` Message-ID: <6b2c8842ef53a3e550aa3de7447c9c3d23bc6772.1728624670.git.ps@pks.im> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: When executing with `--max-count=0` we'll return early from git-grep(1) without performing any cleanup, which causes memory leaks. Plug these. Signed-off-by: Patrick Steinhardt --- builtin/grep.c | 13 ++++++++++--- t/t7810-grep.sh | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/builtin/grep.c b/builtin/grep.c index f17d46a06e4..98b85c7fcac 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -906,6 +906,7 @@ int cmd_grep(int argc, int dummy; int use_index = 1; int allow_revs; + int ret; struct option options[] = { OPT_BOOL(0, "cached", &cached, @@ -1172,8 +1173,10 @@ int cmd_grep(int argc, * Optimize out the case where the amount of matches is limited to zero. * We do this to keep results consistent with GNU grep(1). */ - if (opt.max_count == 0) - return 1; + if (opt.max_count == 0) { + ret = 1; + goto out; + } if (show_in_pager) { if (num_threads > 1) @@ -1267,10 +1270,14 @@ int cmd_grep(int argc, hit |= wait_all(); if (hit && show_in_pager) run_pager(&opt, prefix); + + ret = !hit; + +out: clear_pathspec(&pathspec); string_list_clear(&path_list, 0); free_grep_patterns(&opt); object_array_clear(&list); free_repos(); - return !hit; + return ret; } diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh index af2cf2f78ab..9e7681f0831 100755 --- a/t/t7810-grep.sh +++ b/t/t7810-grep.sh @@ -9,6 +9,7 @@ test_description='git grep various. GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_invalid_grep_expression() { From patchwork Fri Oct 11 05:32:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13832064 Received: from fhigh-a7-smtp.messagingengine.com (fhigh-a7-smtp.messagingengine.com [103.168.172.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 80B3717BD6 for ; Fri, 11 Oct 2024 05:32:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.158 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624749; cv=none; b=JkUig2KNI8T+sDLCmNHwbIzY9QhZzyVIs31QsS+L0X+KxgZCwd1Gnyx1Jxkwh+TEVWVJryayQt30J0vracbv7m+KPSpW10wtmAYflikiI9vetFLpVETHhg69hM0BVZOFj4kX562Ze4UpVXnegA5AocsaWATYhbvbNeqGa1cwDXw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624749; c=relaxed/simple; bh=tgf0OzZ6vuqhuhaUTvcG/E9zISlOXXdkQBRamJsdNIg=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OydyaiTiT7frXNEhaixoJW01EhYPVfd36PAQAel7cq2TSRwTHpkCK4Kf4SoyX/tQLzQqkkvkMvzoBVUUAx1n4dDbZBoLuwPSkBPcAwn9Y6s/0Gd2qCaL7cm4+QJWn5jWLCdqPs7ZuHEmtqwNYHooyU+tqOBkfgliiWLvV4MOd1s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=ehhlwww3; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=ZONdqBLU; arc=none smtp.client-ip=103.168.172.158 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="ehhlwww3"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="ZONdqBLU" Received: from phl-compute-03.internal (phl-compute-03.phl.internal [10.202.2.43]) by mailfhigh.phl.internal (Postfix) with ESMTP id 8C82B11400E9 for ; Fri, 11 Oct 2024 01:32:26 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Fri, 11 Oct 2024 01:32:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1728624746; x=1728711146; bh=AA92HFalRt xRyoO1rIrKdaVpaQIBuLNNOulhPy1mNDY=; b=ehhlwww3iGk4Y0npvb9i3QFFTL WhHNi1VHj4QfJIPZBs9GpLvcy6/kkSo//9ZZDXOiJMEF6VWrBiJ4thzxMkWaD7v8 BFrh1MZsgACtKMK4F3t6uKs6Nl8sWaAEEnUl6QAZLxJkfGMdN/gmIGkGXN4GGF/f OeTDLK/8MuJTXIAgEHnB/KA/9MfqjvlvvFwTB6JJH+dPh2FErYEQRIhmLVAL/G8s DG8oUBKrO90+kjUgyYZa7IekL67/OF+m1a690GriYFeWifsdrkIYJVk40mM/LKQ6 HuVfCgHZPvjuWFdzx/0wMEplj/SMSnmkBvSokebYH+ha7a7IIxN+bVK2ZXvg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1728624746; x=1728711146; bh=AA92HFalRtxRyoO1rIrKdaVpaQIB uLNNOulhPy1mNDY=; b=ZONdqBLU9HnCsxVrqoYI7RocKHB+Y3So8+1Nn/H7ZTwP hIl0DcUUPTWCGtos7G1dDifscXjzqu6lUr706GpuEB9UToEqoMuY7RMv7BFaX0++ g1Jgf+861kPeXQERjdTrzowdsyZES1SrmcUbtR63p8s0TTdDyZ6rh9ug2O9ssc5T 52wIezTufqRe3z5eFp+aIfT9qtHoHBE1o0cCMFsI1mvrRhkCNUvo5etHGdRlmbgz jnnfkWzGStSL9t+nrS/kXhWXYC4/naH4f0QTDNbBg4SnXGeUSr8Bw4cOg9/4QDlA 7NKCEPN4y3xVz3VlyUSVRtXMa9wKJf93Y/G7dH7lcw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdefjedgleelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuf fkfhggtggujgesthdtredttddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhh rghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnhepheekfeefgeegvd egvdeffeehtedttdffjeeuffelgffgheefleffleejvdefheeinecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimhdpnhgspg hrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepghhithesvhhg vghrrdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Fri, 11 Oct 2024 01:32:25 -0400 (EDT) Received: by vm-mail (OpenSMTPD) with ESMTPSA id a6e27ab4 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Fri, 11 Oct 2024 05:31:19 +0000 (UTC) Date: Fri, 11 Oct 2024 07:32:21 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 05/21] revision: fix leaking bloom filters Message-ID: <7527b31a28f4c9d2e689c9749b6f9f0615ba1261.1728624670.git.ps@pks.im> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: The memory allocated by `prepare_to_use_bloom_filter()` is not released by `release_revisions()`, causing a memory leak. Plug it. Signed-off-by: Patrick Steinhardt --- revision.c | 5 +++++ t/t4216-log-bloom.sh | 1 + 2 files changed, 6 insertions(+) diff --git a/revision.c b/revision.c index f5f5b84f2b0..8df75b82249 100644 --- a/revision.c +++ b/revision.c @@ -3227,6 +3227,11 @@ void release_revisions(struct rev_info *revs) clear_decoration(&revs->treesame, free); line_log_free(revs); oidset_clear(&revs->missing_commits); + + for (int i = 0; i < revs->bloom_keys_nr; i++) + clear_bloom_key(&revs->bloom_keys[i]); + FREE_AND_NULL(revs->bloom_keys); + revs->bloom_keys_nr = 0; } static void add_child(struct rev_info *revs, struct commit *parent, struct commit *child) diff --git a/t/t4216-log-bloom.sh b/t/t4216-log-bloom.sh index 3f163dc3969..8d22338f6aa 100755 --- a/t/t4216-log-bloom.sh +++ b/t/t4216-log-bloom.sh @@ -4,6 +4,7 @@ test_description='git log for a path with Bloom filters' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh . "$TEST_DIRECTORY"/lib-chunk.sh From patchwork Fri Oct 11 05:32:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13832065 Received: from fout-a3-smtp.messagingengine.com (fout-a3-smtp.messagingengine.com [103.168.172.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8755A1FA247 for ; Fri, 11 Oct 2024 05:32:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.146 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624752; cv=none; b=WDgYbJoEPJ8UhV6rC45+nB7mU8aZAyhL16CvKGUcW33BU+Ol/Se7lsV5x8/7fT/4PBJzXp17ihDLq31EKYJe8z2IlCE0f4kMU4ff5bZ/qGx7aAuMupU27wNcqaIuXh3ChGuzy6xM6AwF9RIzYWD0Y77RGPH635CpxOGEUJBbv7o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624752; c=relaxed/simple; bh=mdiN6ue/eOZdFWkdYu8EOE/ga50DanGvi8gNXSeh5QU=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=KoUW8vbtpbntV3LPTGFA55WACMelXp8FiM+oSNLRi62YLqrA6PDgxp2knHrmJ6IS0TYQ0Y3D7yM4kPfotu8eOEa4cm5z/VhM1Yitj8/PrpLap8gC9VViK78cWE1FMp8KBgxItYA6Jdj4q/C0N3ggOXrfCcCAdHzz6WG0JzgZn9g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=m6D4WKGB; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=JpYE9Iup; arc=none smtp.client-ip=103.168.172.146 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="m6D4WKGB"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="JpYE9Iup" Received: from phl-compute-12.internal (phl-compute-12.phl.internal [10.202.2.52]) by mailfout.phl.internal (Postfix) with ESMTP id 73D1B1380158 for ; Fri, 11 Oct 2024 01:32:29 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-12.internal (MEProxy); Fri, 11 Oct 2024 01:32:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1728624749; x=1728711149; bh=sJ4deOtsyp fqcT64kwHJU5mmp+as5epFSpTG2Rq+xU4=; b=m6D4WKGBxuwKbnG/9HJez0cbiX 1gwZSKFAR1H7WP6MI1Ttg/gm9Ha4FOOAJZ89TrRGf8rnlMdr7vBlN3JeGwkKCYe7 xGvUbTgede3A010WBCgMa3MzmB6w1kTdZ4Y9qVy+cJ9pYIy1iGqwBPDPbvHjm1Ma Z3nWRiYaa/jd2Y2Cq0oQY0bfVxmZmLAszAfZUOnw4FqpHEJVC2/pRyDHihuMwF5c mh/gQyMobAMQzXSvicKk8hyEPcLMtvdp8rjBiwAMbvrt6VuZS2STYHIqaKCTCgyt quOTcDlkIh/+DwrZLMmsFRVIe0e0x8Eenoi1MR0PPN9RJsX/1AiW6R/1nXxA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1728624749; x=1728711149; bh=sJ4deOtsypfqcT64kwHJU5mmp+as 5epFSpTG2Rq+xU4=; b=JpYE9IupoMYvwlFnIpGYrsx+w3nX3WUb1BXJuKPmWhsi AEHnOjN8UL2dSYgKvsw4LEAiKTxTUH2fCX1lA+9JNLmOSygDCGBaB72kxvBeHwKw niMXjbIUHp1G6RSmjkNpXATaCxWOtP457YHshBUk587GfehCM9KNYh9x9zmi4dEl nhkjpZ+a6oRAnX3QO1CO+ilN85e1uMEEz9kiYThxBcWH1mo1JjGLr6FQ/Nr0fpZU UQr5PA1zD2KXaB4UwSfuqPAtC5Hl0q4enWRcSJ9GGIrokYJ3R8cGsKO8SjKdeqxu pF0pDHd7KQHSTKeQnABQV0ebaOA7MakX1MIgQ795rQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdefjedgleelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuf fkfhggtggujgesthdtredttddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhh rghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnhepieeljeehtdeiie ekhfevkeeviedtvdehhedtudeigfegtdejhffhfedukeeujeehnecuffhomhgrihhnpegu ihhffhhophhtrdhnohenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehpshesphhkshdrihhmpdhnsggprhgtphhtthhopedupdhmohguvgepshhm thhpohhuthdprhgtphhtthhopehgihhtsehvghgvrhdrkhgvrhhnvghlrdhorhhg X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Fri, 11 Oct 2024 01:32:28 -0400 (EDT) Received: by vm-mail (OpenSMTPD) with ESMTPSA id b4235a7e (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Fri, 11 Oct 2024 05:31:22 +0000 (UTC) Date: Fri, 11 Oct 2024 07:32:26 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 06/21] diff-lib: fix leaking diffopts in `do_diff_cache()` Message-ID: <60af98cb2c7752edc7cd5c5fe8173dc5b2522a7b.1728624670.git.ps@pks.im> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: In `do_diff_cache()` we initialize a new `rev_info` and then overwrite its `diffopt` with a user-provided set of options. This can leak memory because `repo_init_revisions()` may end up allocating memory for the `diffopt` itself depending on the configuration. And as that field is overwritten we won't ever free that. Plug the memory leak by releasing the diffopts before we overwrite them. Signed-off-by: Patrick Steinhardt --- diff-lib.c | 1 + t/t7610-mergetool.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/diff-lib.c b/diff-lib.c index 6b14b959629..3cf353946f5 100644 --- a/diff-lib.c +++ b/diff-lib.c @@ -661,6 +661,7 @@ int do_diff_cache(const struct object_id *tree_oid, struct diff_options *opt) repo_init_revisions(opt->repo, &revs, NULL); copy_pathspec(&revs.prune_data, &opt->pathspec); + diff_free(&revs.diffopt); revs.diffopt = *opt; revs.diffopt.no_free = 1; diff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh index 22b3a85b3e9..5c5e79e9905 100755 --- a/t/t7610-mergetool.sh +++ b/t/t7610-mergetool.sh @@ -10,6 +10,7 @@ Testing basic merge tool invocation' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh # All the mergetool test work by checking out a temporary branch based From patchwork Fri Oct 11 05:32:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13832066 Received: from fout-a3-smtp.messagingengine.com (fout-a3-smtp.messagingengine.com [103.168.172.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 051D5208216 for ; Fri, 11 Oct 2024 05:32:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.146 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624754; cv=none; b=j1PVVZ8ye+Fh03Pi8ER3jWbUZEhidZ7XMWOkJmhUWaJ24bWimXTc8Qgc59ONOzoxbrIYsMYH0oz8RYBz+yNYYFbYHj9T00J5Mvfxf9NjI0+j+CG5Oj14/1LR50s+5YN1t3EcWgPSq+8bzAAD3c9P+SgTtWMn3OOZZFoJ7EejTGg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624754; c=relaxed/simple; bh=wAfvhPFldsAk1ENfmTWyT2kjMkc39kSM/wL7UH3uTns=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=R9v5i7VKiF3nEi7BpdHn7uNwpz+nc2T6t0oGzj2F/DNC7Q6RIhUF0vxQTymM7T4pRae65uCNwUGumKIVESWOvAfZF/eBBadGnqTCsC7mzgGy85Va/D0Sidk2zTYkF0z9VcPMkSaXXLMbWRjqu9KCY/1uFsw+wEIjmetEvfQfxEA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=glNCUW5G; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=TFVMIyyJ; arc=none smtp.client-ip=103.168.172.146 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="glNCUW5G"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="TFVMIyyJ" Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfout.phl.internal (Postfix) with ESMTP id 629E51380123 for ; Fri, 11 Oct 2024 01:32:32 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-01.internal (MEProxy); Fri, 11 Oct 2024 01:32:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1728624752; x=1728711152; bh=tZObAy4DHE F/a+fzzNqxX5HuWJEycgm/nu8ulIuXZV4=; b=glNCUW5GlUeksgM/BHvkn4Goxw Uu3l4KvI+r83yPBAwt9eKqDRZyudASPgd/bI8tgrr5frTFTxe7KkMt78MJDDmekK Q8nh4qeqSZOy+7C74VVFqpGjMzW8sOP6nSk8QOHL6m03CMhRA6nkPX/gFAMcVxsj wAVqxq55jnnbsCLWAepRllnIrSf6jPuvCxQNJXnNBBZnasr1msxOTSL8TumrW59r otXyKKXHm4oU46ZFeh5xT/ZJyyvnnxEOlfR+LZRUDwFhPXMQpSHA14d9mBk2rM8P qUxwLM2uRDbn/BmhevzisL1AK8aztePQlAWd2g4ezGP7bXaZrt6M7TSwjj/w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1728624752; x=1728711152; bh=tZObAy4DHEF/a+fzzNqxX5HuWJEy cgm/nu8ulIuXZV4=; b=TFVMIyyJkak1kN686Z8KdYm9t85E/3KNKRfME/9xEB2C yye516mb95i6i4Sgm0SKJWZ4CSqSxJHLnLDmEo2RUBVYfVkXPwcjCgJfeBcNpBBZ L/gLqoXCkzzTq6wBlrG69QKFhjjuLc1Gdvf6Cn53eZ0e1P49J0h+zg8FnkhsXTx6 VX+K/HwO4zJ+aMzVOn9b0FNJkIFgzrBLY8Cm8ykp+eZp3NJm/qsEs0Ad6Fs4TfUu Lc43sa6Jsm5LKPGsPX8MGjvbHAIgpPPwKlYa9FVWw5qU5j9fHmq4FCeMZZITeDI6 B7D8rQ5VfCUCPHPKN5tS+xDO0lR0KUFdcpEp6Eycig== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdefjedgleelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuf fkfhggtggujgesthdtredttddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhh rghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnhepheekfeefgeegvd egvdeffeehtedttdffjeeuffelgffgheefleffleejvdefheeinecuvehluhhsthgvrhfu ihiivgepvdenucfrrghrrghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimhdpnhgspg hrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepghhithesvhhg vghrrdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Fri, 11 Oct 2024 01:32:31 -0400 (EDT) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 6fbcbbb3 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Fri, 11 Oct 2024 05:31:25 +0000 (UTC) Date: Fri, 11 Oct 2024 07:32:29 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 07/21] pretty: clear signature check Message-ID: <5d5f6867f918460001f62aaa78f24cf3cbe53a3c.1728624670.git.ps@pks.im> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: The signature check in of the formatting context is never getting released. Fix this to plug the resulting memory leak. Signed-off-by: Patrick Steinhardt --- pretty.c | 1 + t/t4202-log.sh | 1 + t/t7031-verify-tag-signed-ssh.sh | 1 + t/t7510-signed-commit.sh | 1 + t/t7528-signed-commit-ssh.sh | 1 + 5 files changed, 5 insertions(+) diff --git a/pretty.c b/pretty.c index 6403e268900..098378720a4 100644 --- a/pretty.c +++ b/pretty.c @@ -2032,6 +2032,7 @@ void repo_format_commit_message(struct repository *r, free(context.commit_encoding); repo_unuse_commit_buffer(r, commit, context.message); + signature_check_clear(&context.signature_check); } static void pp_header(struct pretty_print_context *pp, diff --git a/t/t4202-log.sh b/t/t4202-log.sh index 51f7beb59f8..35bec4089a3 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -5,6 +5,7 @@ test_description='git log' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh . "$TEST_DIRECTORY/lib-gpg.sh" . "$TEST_DIRECTORY/lib-terminal.sh" diff --git a/t/t7031-verify-tag-signed-ssh.sh b/t/t7031-verify-tag-signed-ssh.sh index 20913b37134..2ee62c07293 100755 --- a/t/t7031-verify-tag-signed-ssh.sh +++ b/t/t7031-verify-tag-signed-ssh.sh @@ -4,6 +4,7 @@ test_description='signed tag tests' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh . "$TEST_DIRECTORY/lib-gpg.sh" diff --git a/t/t7510-signed-commit.sh b/t/t7510-signed-commit.sh index 0d2dd29fe6a..eb229082e40 100755 --- a/t/t7510-signed-commit.sh +++ b/t/t7510-signed-commit.sh @@ -4,6 +4,7 @@ test_description='signed commit tests' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh GNUPGHOME_NOT_USED=$GNUPGHOME . "$TEST_DIRECTORY/lib-gpg.sh" diff --git a/t/t7528-signed-commit-ssh.sh b/t/t7528-signed-commit-ssh.sh index 065f7806362..68e18856b66 100755 --- a/t/t7528-signed-commit-ssh.sh +++ b/t/t7528-signed-commit-ssh.sh @@ -4,6 +4,7 @@ test_description='ssh signed commit tests' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh GNUPGHOME_NOT_USED=$GNUPGHOME . "$TEST_DIRECTORY/lib-gpg.sh" From patchwork Fri Oct 11 05:32:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13832067 Received: from fhigh-a7-smtp.messagingengine.com (fhigh-a7-smtp.messagingengine.com [103.168.172.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 18F5C208966 for ; Fri, 11 Oct 2024 05:32:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.158 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624757; cv=none; b=VbNFVsDX1ST1SFzC6hZ4KiUXLqRwTdpdh47ou0DjmziF5c7NvE/0qjPvFmvqCYDLrWZP2Jicn2+l0oDmndFLVas6gHSUasFeAv6HzpeX69j1ft8X0axUjWmVlhOdZkp8tM0Zg28Qt1SGAi1oGJkLwECx96vYJKcSEPjNHQJC+V8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624757; c=relaxed/simple; bh=QTKqjDdWblpuH/dGgXNI7crp3s7Mktrmf+Vs+yBv+58=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=tauv4efCzWnb3xnee2UoN8bApu9xj20NApaQsPCtJ9+se9ZTGHn2Q58k8JM1tEgK+q4P8mKI1hxK8LNWLe34eTWv4+/Kvt1oi81FiTfpUL7t/PH0fKtQulEofycmDkPSNDlC+npg0Qjnm61T59OevOfrdDhF2w4Gh8PZjUJli8Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=NRT6QTbR; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=oqfib9UC; arc=none smtp.client-ip=103.168.172.158 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="NRT6QTbR"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="oqfib9UC" Received: from phl-compute-03.internal (phl-compute-03.phl.internal [10.202.2.43]) by mailfhigh.phl.internal (Postfix) with ESMTP id 3AD241140129 for ; Fri, 11 Oct 2024 01:32:35 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Fri, 11 Oct 2024 01:32:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1728624755; x=1728711155; bh=9hpBI14F3o obSsjIShGZSbESjCVSiyCsYPH5sxYlEbE=; b=NRT6QTbRPGGAYVCUhBvqydDesb M1ZMTLWthAFNxoDSbw9WRMAbqbF5DByBeJYTxjeHGzJWyOyGsgSHEsWgjZYvuhxU PXay0uvY063QLGtf7wurF1nPK+7sMp1Q0lxNmTjtvwTt/wR5wDPiT13s1hEmj1Vm jPE7ZX25lt+H+fqiza2t2EmTG/gh5YZezLiTUPm8/bCojvqlabXW7njcyLmybK6c wOuEqiu3ADg90sZ1Eh1YFVZZrVxMDMe+5Fzv37S1HIpdAUPro60VDu5xQQBvhXDW D7bqjoyWXQZHpu01ugwZMiOuh/LFPS+EyPTCT/CJgxHju6f3dNL1aZvPxINQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1728624755; x=1728711155; bh=9hpBI14F3oobSsjIShGZSbESjCVS iyCsYPH5sxYlEbE=; b=oqfib9UCuK74vFG7akPa/nrvt3Ri6BR07BqXufg1/oUV /O/fIF5TI/VThXG52LFizVJm32DdnpxprOhIWz1xLsGp+I77IpFkKI8fDpctC6xO oqocpBANP7TKYE+mYQyo5fCwHk5kOm/hLGvuEy9HFs8zSONv8iBz5hltag5kCot7 trSUflYiCiLNfzX3esxE734PLIyduUsMpjD+lKyr7vf9r7BScCEzu1dj2jE4qbw+ X4HzcmoVqWOT6cxdBoc8QGyMu+ifRBuV5DGe0bXVOS9B8Z/LiC/h4kCmPzykgFOj 2aPbrUJEqD/q8a+NTrvuYQLeBvxUTmGqRVPILKnOrQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdefjedgleelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuf fkfhggtggujgesthdtredttddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhh rghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnhepheekfeefgeegvd egvdeffeehtedttdffjeeuffelgffgheefleffleejvdefheeinecuvehluhhsthgvrhfu ihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimhdpnhgspg hrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepghhithesvhhg vghrrdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Fri, 11 Oct 2024 01:32:34 -0400 (EDT) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 08754e6f (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Fri, 11 Oct 2024 05:31:28 +0000 (UTC) Date: Fri, 11 Oct 2024 07:32:32 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 08/21] upload-pack: fix leaking URI protocols Message-ID: <0d503e40194c5d1912c7dd8a23f685546c490027.1728624670.git.ps@pks.im> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: We don't clear `struct upload_pack::uri_protocols`, which causes a memory leak. Fix this. Signed-off-by: Patrick Steinhardt --- t/t5702-protocol-v2.sh | 1 + upload-pack.c | 1 + 2 files changed, 2 insertions(+) diff --git a/t/t5702-protocol-v2.sh b/t/t5702-protocol-v2.sh index 1ef540f73d3..ed55a2f7f95 100755 --- a/t/t5702-protocol-v2.sh +++ b/t/t5702-protocol-v2.sh @@ -7,6 +7,7 @@ TEST_NO_CREATE_REPO=1 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh # Test protocol v2 with 'git://' transport diff --git a/upload-pack.c b/upload-pack.c index 6d6e0f9f980..b4a59c3518b 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -166,6 +166,7 @@ static void upload_pack_data_clear(struct upload_pack_data *data) object_array_clear(&data->extra_edge_obj); list_objects_filter_release(&data->filter_options); string_list_clear(&data->allowed_filters, 0); + string_list_clear(&data->uri_protocols, 0); free((char *)data->pack_objects_hook); } From patchwork Fri Oct 11 05:32:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13832068 Received: from fhigh-a7-smtp.messagingengine.com (fhigh-a7-smtp.messagingengine.com [103.168.172.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC65D207A07 for ; Fri, 11 Oct 2024 05:32:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.158 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624759; cv=none; b=kXK4Py3sy8qSCYYYwBXwhxwv5G0BiccxRJA4HP0HrozIRFc6VAyd6E3SZbryatsof6WrXIjIidD7fHsy8CCO+jPswcSjLS+Iad0MJ41pbFj2uOAYFCc/oOr5gmDiSuqa7lVGFBdfKkV+KvOTg0Ej72djUEI7EA/9eKG5olJRr+c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624759; c=relaxed/simple; bh=bBi4qB3iFZLBb8pz/84IHwjAnposOszMOzZ2eKrmric=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=UeDfo2zrFafR/74GlP83D2qy4LQYfR0NRlBesU4phuGJScYB4ghMQ70lesBkjFK44ptZ8Zztxm0NFApUEW0Bs7jymCcPRyZceF+vOoC7LzzzErtdX1jRREp+avEEXigzcoRq9UiqFZRAR8GMESqXLTnnimBY5chHWXGet+yydyo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=rdqwJCtr; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=mLfk3OuK; arc=none smtp.client-ip=103.168.172.158 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="rdqwJCtr"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="mLfk3OuK" Received: from phl-compute-12.internal (phl-compute-12.phl.internal [10.202.2.52]) by mailfhigh.phl.internal (Postfix) with ESMTP id 16CAA1140139 for ; Fri, 11 Oct 2024 01:32:37 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-12.internal (MEProxy); Fri, 11 Oct 2024 01:32:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1728624757; x=1728711157; bh=sYRnfP4hGi 0Olig43R02iSA1smd3zS6lNqahH/JzB2Y=; b=rdqwJCtrVT6V2UpyrERjW8kDgD JqIw0FM8wS/T2bS5l/6cMj1bFdPKiC2OJFrOojdBMhsYHTgnIDHjBOLuNplpHtb5 9HKlXDmzb5nrAvnfVJOVSwumIDWVyrim3dkCrWq+caIstH6KY7Hq+9A4ohIr948H CYYS1j61DO1L+dxP32Vohqg77iIWl491yofqXMRwDiIN087Lx4600Hp2GcMe1DpA mxe2TmTNm+VFZE0Cq7o0Z+J4RwQfYum79F1BeRiDLg/zvBHlMjwdNOcwTENrvZWt kgoUVJDrvuWaidv+HKeJtWvSgpnRcgDksXJQZaRsna1And1/6G69kRZw0Rug== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1728624757; x=1728711157; bh=sYRnfP4hGi0Olig43R02iSA1smd3 zS6lNqahH/JzB2Y=; b=mLfk3OuK2Avz+CUG6jFvxN11HlBhk1UCTZQNS2NUH84Y 2XYGsaOI3xup3eP/WjRR7SBarSzrmNZQc7LwwLQV47kgBqmKnQKo767wrdKURiAb y2kmuYZzw/zhiNw+4Zu+gqaF+RzLBByicZFLQBMnNWlRXCQLGGe1/R6cqlubDNWI P/iQ5a0EYu9t+8Uitrx9utaSUN6rpchBJaMWp7/eA3yXfBZ0j3hUByEs52cgFkz0 sxgJQOpywCm9w+1AXrYGPM9a2v7OlmehWv8uYk3Vs93tGW64i6KLPbTD2X81VVYQ sYD/twQTQp5K0fqyvyqeWH5tf+niJXEpCxvEUHOjQA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdefjedgleelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuf fkfhggtggujgesthdtredttddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhh rghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnhepheekfeefgeegvd egvdeffeehtedttdffjeeuffelgffgheefleffleejvdefheeinecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimhdpnhgspg hrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepghhithesvhhg vghrrdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Fri, 11 Oct 2024 01:32:36 -0400 (EDT) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 3eec2174 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Fri, 11 Oct 2024 05:31:30 +0000 (UTC) Date: Fri, 11 Oct 2024 07:32:35 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 09/21] builtin/commit: fix leaking change data contents Message-ID: <9f967dfe5d55ca7150bf3e118279388290f7d28c.1728624670.git.ps@pks.im> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: While we free the worktree change data, we never free its contents. Fix this. Signed-off-by: Patrick Steinhardt --- builtin/commit.c | 9 ++++++++- t/t7500-commit-template-squash-signoff.sh | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/builtin/commit.c b/builtin/commit.c index 8db4e9df0c9..18a55bd1b91 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -728,6 +728,13 @@ static void prepare_amend_commit(struct commit *commit, struct strbuf *sb, repo_unuse_commit_buffer(the_repository, commit, buffer); } +static void change_data_free(void *util, const char *str UNUSED) +{ + struct wt_status_change_data *d = util; + free(d->rename_source); + free(d); +} + static int prepare_to_commit(const char *index_file, const char *prefix, struct commit *current_head, struct wt_status *s, @@ -991,7 +998,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix, s->use_color = 0; committable = run_status(s->fp, index_file, prefix, 1, s); s->use_color = saved_color_setting; - string_list_clear(&s->change, 1); + string_list_clear_func(&s->change, change_data_free); } else { struct object_id oid; const char *parent = "HEAD"; diff --git a/t/t7500-commit-template-squash-signoff.sh b/t/t7500-commit-template-squash-signoff.sh index 4dca8d97a77..379d3ed3413 100755 --- a/t/t7500-commit-template-squash-signoff.sh +++ b/t/t7500-commit-template-squash-signoff.sh @@ -7,6 +7,7 @@ test_description='git commit Tests for template, signoff, squash and -F functions.' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh . "$TEST_DIRECTORY"/lib-rebase.sh From patchwork Fri Oct 11 05:32:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13832069 Received: from fout-a3-smtp.messagingengine.com (fout-a3-smtp.messagingengine.com [103.168.172.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0139B208993 for ; Fri, 11 Oct 2024 05:32:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.146 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624762; cv=none; b=ALD8XPSDFrRlcZd4tPuAZFkVjSHd54Lg5qWZIAGqPilQJ5qFKRq1Dioy4U9np2CY00Tq/p4jA4uY7YoY2dG1Zs/UdqkM8Q5XrQeejf4ZZeZ/I9KgkgshryX89b+Uo9NX+qWRGd1bqeYvnNhQFajwuwJqRpHkV6CdhYzaOR04QY8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624762; c=relaxed/simple; bh=uGVslUYdt/uDwZUxtKTdHrcHada0/VnuDqYlTcFKQhY=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=tG1qOg4MViyvYIeJJZQ8wsYhCIWTgfOf+Km7FbEWHIqX2JLAquvQXxANJvdlJ7Fu1E3EetcQLlsLS4cAvRp6ftsBihaMD9hYEDFDtvSppvNJw5T0Js4ckmpmoXB1xy23vD311SHzH6nRd0kb2d0rcN6ksc6SQ+nepgYVQQ1vbBI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=OPVB0GgF; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=XStCzRR1; arc=none smtp.client-ip=103.168.172.146 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="OPVB0GgF"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="XStCzRR1" Received: from phl-compute-03.internal (phl-compute-03.phl.internal [10.202.2.43]) by mailfout.phl.internal (Postfix) with ESMTP id EA719138019D for ; Fri, 11 Oct 2024 01:32:39 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Fri, 11 Oct 2024 01:32:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1728624759; x=1728711159; bh=IkbFydlBJt CbeeAxjfuGaV6+f7pnlS6r1oCsHP3w6LE=; b=OPVB0GgFs8Fg0FdP55uqL3ZZ1O U+DVyYcC5oLCLHtOEfvvFdpEgoM3y5Ue84dQfHhCpNQ/Hh0tWwN08GL2zDxz/cUj AKlK7YBU74CPceeL0qd304m3XE98PJe3eygDvZ3Zn4/+jXd5KO+Y7xaocQWpSzmZ 6pCEnejA56TdEcdH1ifoh+bMjS9U91sUx2g0z6drPSYz+ivqB95MfnoSDDbefe6y pqa01s3rqSqvFCy7BopuIPTMw1LtHAMhwoVIA6xs7t/Qux4sWKTEdS/MbdX7DT8l ooEu1lql80vBRrJ6SFlSUMKHR7SoZcTLv4jiR1qWdeNJ8TfPP2Qioi+X9AhQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1728624759; x=1728711159; bh=IkbFydlBJtCbeeAxjfuGaV6+f7pn lS6r1oCsHP3w6LE=; b=XStCzRR1GtALT+y6cqR16OY7nQ9PLbnjWDfAAgGjshTZ mFAwaU37DCQscSPTALPynA3IfFCpooB+biDzJr1ctdrLdrCFP/V29RGdUXpp62Wy OuytczptVMSanc814Z8GLj3wltfM7nKz+SETPCRQtK8TeEE65eZqLCtHyYs4MxoW +ytyMB+xSjZAl4euDwo84W2PQb3sA6sMvTnuTV5XCBh0Begb2QxhOQGxnIu0HaJw KsitYIeis51U9+NfQO0z+Gt2rwGiA4Qay/jv3DfrNbizYoncYc6fvehUNz9DE10m +vLarPZtgrXsRnouAlJbRfTmUnEPycIUXhpHUEOS5g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdefjedgleelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuf fkfhggtggujgesthdtredttddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhh rghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnhepheekfeefgeegvd egvdeffeehtedttdffjeeuffelgffgheefleffleejvdefheeinecuvehluhhsthgvrhfu ihiivgepvdenucfrrghrrghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimhdpnhgspg hrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepghhithesvhhg vghrrdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Fri, 11 Oct 2024 01:32:39 -0400 (EDT) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 7cbec7a4 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Fri, 11 Oct 2024 05:31:33 +0000 (UTC) Date: Fri, 11 Oct 2024 07:32:37 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 10/21] trailer: fix leaking trailer values Message-ID: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Fix leaking trailer values when replacing the value with a command or when the token value is empty. Signed-off-by: Patrick Steinhardt --- t/t7513-interpret-trailers.sh | 1 + trailer.c | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/t/t7513-interpret-trailers.sh b/t/t7513-interpret-trailers.sh index 0f7d8938d98..38d6ccaa001 100755 --- a/t/t7513-interpret-trailers.sh +++ b/t/t7513-interpret-trailers.sh @@ -5,6 +5,7 @@ test_description='git interpret-trailers' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh # When we want one trailing space at the end of each line, let's use sed diff --git a/trailer.c b/trailer.c index 682d74505bf..5c0bfb735a9 100644 --- a/trailer.c +++ b/trailer.c @@ -249,17 +249,23 @@ static char *apply_command(struct conf_info *conf, const char *arg) static void apply_item_command(struct trailer_item *in_tok, struct arg_item *arg_tok) { if (arg_tok->conf.command || arg_tok->conf.cmd) { - const char *arg; + char *value_to_free = NULL; + char *arg; + if (arg_tok->value && arg_tok->value[0]) { - arg = arg_tok->value; + arg = (char *)arg_tok->value; } else { if (in_tok && in_tok->value) arg = xstrdup(in_tok->value); else arg = xstrdup(""); + value_to_free = arg_tok->value; } + arg_tok->value = apply_command(&arg_tok->conf, arg); - free((char *)arg); + + free(value_to_free); + free(arg); } } @@ -1114,6 +1120,7 @@ void format_trailers(const struct process_trailer_options *opts, if (item->token) { struct strbuf tok = STRBUF_INIT; struct strbuf val = STRBUF_INIT; + strbuf_addstr(&tok, item->token); strbuf_addstr(&val, item->value); @@ -1124,7 +1131,7 @@ void format_trailers(const struct process_trailer_options *opts, * corresponding value). */ if (opts->trim_empty && !strlen(item->value)) - continue; + goto next; if (!opts->filter || opts->filter(&tok, opts->filter_data)) { if (opts->separator && out->len != origlen) @@ -1145,9 +1152,10 @@ void format_trailers(const struct process_trailer_options *opts, if (!opts->separator) strbuf_addch(out, '\n'); } + +next: strbuf_release(&tok); strbuf_release(&val); - } else if (!opts->only_trailers) { if (opts->separator && out->len != origlen) { strbuf_addbuf(out, opts->separator); From patchwork Fri Oct 11 05:32:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13832070 Received: from fhigh-a7-smtp.messagingengine.com (fhigh-a7-smtp.messagingengine.com [103.168.172.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 69C3E2F26 for ; Fri, 11 Oct 2024 05:32:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.158 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624768; cv=none; b=q2kvCCtQJpoJthrka+r+Z6j46LYHyWc/VMtaPD2FfsQuk2tLP3+acRS6B2nKuaWeGLKNGRuSAl0ICTR0hBekQ/mk6rJpv9zI4CFlwXvo0+Dia8we5g5xkRwQhcYHsg+K/4+oF14asMakzXtbCA9WtYR7OKgPeKzr16j5LPuR7Oc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624768; c=relaxed/simple; bh=zTeJiXPBiztvR/WmiLHPyk5vYo6fEV/yaydKRGyxB8Q=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=TFR1IYK75xNgTTtO0YyNJWzmxcVM3IYTHegmAUko8SQ5htTngiO/7n+e31Fwlflfi0ix9RAXsxSiJmyzq7XInCXIj45AsYLDeP4qiTOp7IT/o4tXLvSliPYj0VfUhy+4cUd1Mcfkeqmr/RpNDJPCPUEOLR5bsdzpBVB4ym3zF/c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=IAth5bcJ; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=GkxWMELH; arc=none smtp.client-ip=103.168.172.158 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="IAth5bcJ"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="GkxWMELH" Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfhigh.phl.internal (Postfix) with ESMTP id C75EF1140129 for ; Fri, 11 Oct 2024 01:32:45 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-01.internal (MEProxy); Fri, 11 Oct 2024 01:32:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1728624765; x=1728711165; bh=qhFa6x0GE6 5zxmivZ3Ba8v98/skC1YHRXOt2GQ+Ugbk=; b=IAth5bcJav86Y8CEbLmqkdVCOJ Y+BXeRREG39bmYRr/Cy58U45MaIXsjsn7srqLWVIedm8hIWI/oLHWesIaWGhUBLR pWWWHOeXtxIVBJyGaeqkSLDaJucIZNBRA18ZRfsy8dzkIrnUdf0vS72yzDbYwI/H dl+eKw8+tpPvlSb2d5ZaD11DJLtPLnrMQR7lVVjtBqU9lxL1ffdCisBgwBn9yL3z /fueFj8BzVOYgC5T+VW/IJhK3bLRbkel+ANvK74EQb/cbfjR5ixvev+oso1AzF0L GLhvnJhE/d56QzuJU6Ai4yKL+6eBM4XwO8Kh/nl4/BUSC5W4ADQG5c8g7NVA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1728624765; x=1728711165; bh=qhFa6x0GE65zxmivZ3Ba8v98/skC 1YHRXOt2GQ+Ugbk=; b=GkxWMELHXW0H+3YoHNZ7O8r/sBCL63gDauutl3yr8Y3G DZ8W4tgnrJf8jUGeJa08QYqDC6ITsMudCq4Gsdv6sq9Du9wYLolilN5/NKTbH5DG HXflUqRvbr8F7a7epbnFri5MOKsfKxpIaU2GWXfPEsdJMVtYM2BcU5jHdrdK1vyZ Tt6Z6iDQR1Zt2wz2zYuXYlkclMjryOGDK4wV2U6kPPkMbmjvzzmQ8kkuaV/08foi ArcT4Kz+WjkjtqjZWwrwvyPuNuaDE3WPXjnsRZdbJKCeb8k/EVjEthfO4vvL7OF0 APNHjEAu1YAxIUzlSl5qC2Na0Q80d1F9x0IO0+42TA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdefjedgleelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuf fkfhggtggujgesthdtredttddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhh rghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnhepheekfeefgeegvd egvdeffeehtedttdffjeeuffelgffgheefleffleejvdefheeinecuvehluhhsthgvrhfu ihiivgepfeenucfrrghrrghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimhdpnhgspg hrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepghhithesvhhg vghrrdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Fri, 11 Oct 2024 01:32:45 -0400 (EDT) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 8bc6d3a6 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Fri, 11 Oct 2024 05:31:38 +0000 (UTC) Date: Fri, 11 Oct 2024 07:32:40 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 11/21] builtin/commit: fix leaking cleanup config Message-ID: <8ca4344ed8674b6c40b5fee96d23f64517c7b9e0.1728624670.git.ps@pks.im> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: The cleanup string set by the config is leaking when it is being overridden by an option. Fix this by tracking these via two separate variables such that we can free the old value. Signed-off-by: Patrick Steinhardt --- builtin/commit.c | 17 ++++++++++++----- t/t7502-commit-porcelain.sh | 1 + 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/builtin/commit.c b/builtin/commit.c index 18a55bd1b91..71d674138c9 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -135,7 +135,7 @@ static struct strvec trailer_args = STRVEC_INIT; * is specified explicitly. */ static enum commit_msg_cleanup_mode cleanup_mode; -static char *cleanup_arg; +static char *cleanup_config; static enum commit_whence whence; static int use_editor = 1, include_status = 1; @@ -1387,8 +1387,6 @@ static int parse_and_validate_options(int argc, const char *argv[], if (0 <= edit_flag) use_editor = edit_flag; - cleanup_mode = get_cleanup_mode(cleanup_arg, use_editor); - handle_untracked_files_arg(s); if (all && argc > 0) @@ -1636,8 +1634,10 @@ static int git_commit_config(const char *k, const char *v, include_status = git_config_bool(k, v); return 0; } - if (!strcmp(k, "commit.cleanup")) - return git_config_string(&cleanup_arg, k, v); + if (!strcmp(k, "commit.cleanup")) { + FREE_AND_NULL(cleanup_config); + return git_config_string(&cleanup_config, k, v); + } if (!strcmp(k, "commit.gpgsign")) { sign_commit = git_config_bool(k, v) ? "" : NULL; return 0; @@ -1658,6 +1658,7 @@ int cmd_commit(int argc, struct repository *repo UNUSED) { static struct wt_status s; + static const char *cleanup_arg = NULL; static struct option builtin_commit_options[] = { OPT__QUIET(&quiet, N_("suppress summary after successful commit")), OPT__VERBOSE(&verbose, N_("show diff in commit message template")), @@ -1757,6 +1758,12 @@ int cmd_commit(int argc, if (verbose == -1) verbose = (config_commit_verbose < 0) ? 0 : config_commit_verbose; + if (cleanup_arg) { + free(cleanup_config); + cleanup_config = xstrdup(cleanup_arg); + } + cleanup_mode = get_cleanup_mode(cleanup_config, use_editor); + if (dry_run) return dry_run_commit(argv, prefix, current_head, &s); index_file = prepare_index(argv, prefix, current_head, 0); diff --git a/t/t7502-commit-porcelain.sh b/t/t7502-commit-porcelain.sh index b37e2018a74..84f1ff52b67 100755 --- a/t/t7502-commit-porcelain.sh +++ b/t/t7502-commit-porcelain.sh @@ -5,6 +5,7 @@ test_description='git commit porcelain-ish' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh commit_msg_is () { From patchwork Fri Oct 11 05:32:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13832071 Received: from fhigh-a7-smtp.messagingengine.com (fhigh-a7-smtp.messagingengine.com [103.168.172.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 477671F9AA7 for ; Fri, 11 Oct 2024 05:32:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.158 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624770; cv=none; b=OUCzntfrVL8Dg2yPbXIT5XxU2h+PFjbMgvE7FpulhJoyzMlvmE1rFF9WK9WT3JJ8Dtu/sRJ31vcGApTbb+uGzCBar6wvAW2JUIccWeeUJ/EQwz8I0rbct/I++RlCj3xPK+mhwBZF80JAUO/n1sMttZcNNKg36du/cAodacFlmSI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624770; c=relaxed/simple; bh=bAzSPxkum0PKfLT2dnzzCjEm3sq8Pmj1lJB8C4u5v0g=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FrXTkgYlP6bK+X1Erbl/UQN777Tud9ebZgIl+cuxxSR+cGWxe/LPpaesDGndzb7KQGlC/vsLa+4rnTYyOn0HlqoX19KWLljFmyHyxnKy5Qti7lmul0Pgw+68j5GFzc9NjEYM1Vy8Ru76pBRDn6oHZ6GPVuJO+fHYVBU56+3gfMI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=QgwLen/I; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=buMg6nsI; arc=none smtp.client-ip=103.168.172.158 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="QgwLen/I"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="buMg6nsI" Received: from phl-compute-03.internal (phl-compute-03.phl.internal [10.202.2.43]) by mailfhigh.phl.internal (Postfix) with ESMTP id 9A15411400C4 for ; Fri, 11 Oct 2024 01:32:48 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Fri, 11 Oct 2024 01:32:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1728624768; x=1728711168; bh=Pteuko61CJ aREjl9f7VpsYwMxjDuAXNNLetM6KewWc0=; b=QgwLen/IkUi3C3H8XoL5Jar4NE G34JSUv6pue7m5yZgf3L+PXGCy0JoyYUSh0b3A0pYPSrYzrLX27Tk2Vt8mgRxPM7 9VzZOycFCv501caed8QtM8q0RED8nJT+XjjCrakdGCzINEzzoAGp4UDuVASyjyfm IYmclvKmTsEARdzgR558SZ0PoIBNEtWUvTK507TV0CJ0v8LjLgI850cTn2PsGAWu DIxh2smYcbb3X38Zp6KikJJT/MDP4ay4njwXlsFs41szG3Z0bECrTWEgFDHYZu+v QOVyTm+jhMuaP3CDl5D4mqFmUvNT+h/zpezeBQ4th5N3lYs4eonv4/J7W1ww== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1728624768; x=1728711168; bh=Pteuko61CJaREjl9f7VpsYwMxjDu AXNNLetM6KewWc0=; b=buMg6nsIoVoojHoNi6wBFJByYat20BvfsMhQG8LlHoz4 s3aTvLloke0GUg0sCLFpdZesrCXKx+lb3NnPlPIdMdz4gidqknPBaLQECe1Gpo4x 1FK8pfwEBk2shtl3nlSZO1VAc/VGG1XXj6/s0NMTynjEfmTqOy5VG30ftsGMG7CM i6JZCldMn40Wse6MZyJ6ZVtzABMsmcW8VjUBmJ4NjdNZtnpnzLTDnAq9H4A4sTzE yASad3SRckG0kZgJ21x0dTJNPl9i6YIz509UFn8wz3h8P2rtuYFXGQNersuJsAg9 LNJqoTl1flc7KHQzxx1gAGsIo8nxXY+vlWG8jC/uSQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdefjedgleelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuf fkfhggtggujgesthdtredttddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhh rghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnhepheekfeefgeegvd egvdeffeehtedttdffjeeuffelgffgheefleffleejvdefheeinecuvehluhhsthgvrhfu ihiivgepfeenucfrrghrrghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimhdpnhgspg hrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepghhithesvhhg vghrrdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Fri, 11 Oct 2024 01:32:47 -0400 (EDT) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 16bff9cc (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Fri, 11 Oct 2024 05:31:41 +0000 (UTC) Date: Fri, 11 Oct 2024 07:32:46 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 12/21] transport-helper: fix leaking import/export marks Message-ID: <16d969ed7b16a4de34484b70616291512a686005.1728624670.git.ps@pks.im> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Fix leaking import and export marks for transport helpers. Signed-off-by: Patrick Steinhardt --- t/t5801-remote-helpers.sh | 1 + transport-helper.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh index d21877150ed..d4882288a30 100755 --- a/t/t5801-remote-helpers.sh +++ b/t/t5801-remote-helpers.sh @@ -8,6 +8,7 @@ test_description='Test remote-helper import and export commands' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh . "$TEST_DIRECTORY"/lib-gpg.sh diff --git a/transport-helper.c b/transport-helper.c index 013ec79dc9c..bc27653cdee 100644 --- a/transport-helper.c +++ b/transport-helper.c @@ -399,6 +399,8 @@ static int release_helper(struct transport *transport) int res = 0; struct helper_data *data = transport->data; refspec_clear(&data->rs); + free(data->import_marks); + free(data->export_marks); res = disconnect_helper(transport); free(transport->data); return res; From patchwork Fri Oct 11 05:32:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13832072 Received: from fhigh-a7-smtp.messagingengine.com (fhigh-a7-smtp.messagingengine.com [103.168.172.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 656B4209662 for ; Fri, 11 Oct 2024 05:32:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.158 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624773; cv=none; b=QIhmYpavkslblqjn6DViI6BQ0ZOv1fuM89TjQ5TE1oVmMAnjEKFH9B5SZpJbbwst2I0oc6002IJFIalDoO00/+lIY3N675jxelo/YKMVAaS1ejI32zUuCf/fvA0146J0GZOz0viS9DXZZ0zq8ynen8MRR+qwmKV9z4IKQmUWZ6c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624773; c=relaxed/simple; bh=59KpGOuy2cH2jC7/dRXpKCeGMeT3DZ83tCE8QEjsopg=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=tI1jCSyM/Oujje+w9blIoijX0FoddYOX7x93LeMQ8Cm0rT6IZ2MXK4lMa+X23X7VZ6bH5q07ypr9EY0fgkLCUtArKbn0B1XBMREOilY5A39+NXiwcYXBPL88h7zdaoi9schjNl8kjEzqnk+9wMPuEy7HrL9rqD8CmaBLgecbZyY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=j6BXUpMI; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=d+qlTwwq; arc=none smtp.client-ip=103.168.172.158 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="j6BXUpMI"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="d+qlTwwq" Received: from phl-compute-06.internal (phl-compute-06.phl.internal [10.202.2.46]) by mailfhigh.phl.internal (Postfix) with ESMTP id 79D96114012A for ; Fri, 11 Oct 2024 01:32:51 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Fri, 11 Oct 2024 01:32:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1728624771; x=1728711171; bh=Tfv8KEuPps Xrz70WMtkezaBgwKtmBBGsp3/EIgSPKbg=; b=j6BXUpMIENTXUSJhSJ3rrxU4OW pQ8SQQ8a6SkaWYaS6b68ADEdjr77VbU6Cwlsv2ogzWTBbe5gEYMD4MCGTr8QNxJW i8xdgeS+N3XAMffrG0Ht5/fJX1eH5Pd14mb4XllBmMY20QkkJZiy+yNX1tSQdCLi uN88tOMT+HGbOVEF/c+T3IKiOrv58J/Dl+wqv2yQp5DdG1zhfOe7QGBSzIlEnby0 cDh1hPX5Q8tQUhKsNNrG2tL6+Ep5PFx7y4vM63pPY6rUHmmrOBB7owVYQvg2dBTb xtariq28F3yHDcNGYOwmxJLr5ODB+X4tTR7q1hFFCe8F3iCdoP27Iw9dLJWw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1728624771; x=1728711171; bh=Tfv8KEuPpsXrz70WMtkezaBgwKtm BBGsp3/EIgSPKbg=; b=d+qlTwwq4QdkHXwgzM8pmpqBXWCs2qRRbSBhL+jcJ508 G5jvzEVeOyKbIb/4rLCbINrZYcC6QjuHYAAP/n3xFB10nytXeAZOHEK/vMtmbEtX EHHYFmaKig8TE6lhg3PqpZO+mNoEKLaEKKr7pQb1JEnbZ2IQG3VPP59yC+robzoa 0EypzfhDXFC+x9iynsDzLCTJgXaoX2Sw33McdIaRtkR/nwdUWfA3WNOgaBlyDDBC EUaC6KxU28gX6bTpSypwi8yfiAtpVaSGJvlN/SaSwhVZvbNICDz17rb0HOk4AbAN 91jV8Oyj9yPhMrej0nlWMPhBQBL/YQqIBSMkiegqkg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdefjedgleelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuf fkfhggtggujgesthdtredttddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhh rghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnhepheekfeefgeegvd egvdeffeehtedttdffjeeuffelgffgheefleffleejvdefheeinecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimhdpnhgspg hrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepghhithesvhhg vghrrdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Fri, 11 Oct 2024 01:32:50 -0400 (EDT) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 2eda4aa5 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Fri, 11 Oct 2024 05:31:44 +0000 (UTC) Date: Fri, 11 Oct 2024 07:32:48 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 13/21] builtin/tag: fix leaking key ID on failure to sign Message-ID: <9e4bc5bf73f47d59af012ae3e5798570570722ba.1728624670.git.ps@pks.im> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: We do not free the key ID when signing a tag fails. Do so by using the common exit path. Signed-off-by: Patrick Steinhardt --- builtin/tag.c | 2 +- t/t7004-tag.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/builtin/tag.c b/builtin/tag.c index 93d10d59157..c37c0a68fda 100644 --- a/builtin/tag.c +++ b/builtin/tag.c @@ -164,7 +164,7 @@ static int do_sign(struct strbuf *buffer, struct object_id **compat_oid, int ret = -1; if (sign_buffer(buffer, &sig, keyid)) - return -1; + goto out; if (compat) { const struct git_hash_algo *algo = the_repository->hash_algo; diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh index b1316e62f46..42b3327e69b 100755 --- a/t/t7004-tag.sh +++ b/t/t7004-tag.sh @@ -10,6 +10,7 @@ Tests for operations with tags.' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh . "$TEST_DIRECTORY"/lib-gpg.sh . "$TEST_DIRECTORY"/lib-terminal.sh From patchwork Fri Oct 11 05:32:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13832073 Received: from fhigh-a7-smtp.messagingengine.com (fhigh-a7-smtp.messagingengine.com [103.168.172.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 014E91F9AA7 for ; Fri, 11 Oct 2024 05:32:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.158 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624775; cv=none; b=qtRN8jO+K+5V5ZuuWL0aC9PvKXv0cpnG4s8+V/Va6p8BPK9jY/NCj7wMnqJpRukYUkabSwsBZ5n3kGEf9/Kzt9KoeQWEbUkO+xzV+oiB7TIt2g3XMTea598FbC6buNbUs9pQKcZnhidYFL2Dly4/aikwKVmBQiAF875RoaTsXzs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624775; c=relaxed/simple; bh=8m04HFlqdCTdA6Ohgz4zVvskbeSsPm0QI5Xq+CN3D0I=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=NR61+3VeH4/gTLxPlDKRW1sh0E5iiIiRLCqlpLhJkg+aZIrBQnysEOjxxGEd7VKLLpWL1Ue5c7/vBpMOeY8oqmLXjNtYkk84Em3NxfkkaZuya00atr7PyVt9iVtKHNhHfvoRmd6fSCAxiCa+CWAiYd4dRFXTHA4Ochb/9EKDcSg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=UL8bTDzb; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=jNwY0ehU; arc=none smtp.client-ip=103.168.172.158 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="UL8bTDzb"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="jNwY0ehU" Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfhigh.phl.internal (Postfix) with ESMTP id 5F0D31140135 for ; Fri, 11 Oct 2024 01:32:53 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-01.internal (MEProxy); Fri, 11 Oct 2024 01:32:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1728624773; x=1728711173; bh=bAFKi7QxuD Ddn5Ffp9cMNlApG+6az0YdD1+EC6TZ5pM=; b=UL8bTDzbNx2Q+e93+geikFYFwg Yem1RNA15/dZkGCEaYniYtckAwu3SrJ2T0tyrsEj3BuSSyU5VCw9pHtigMtUu3TE /d/sj/AVZCRlKgPDOlSQDwPxdI9vlU14Qy6OjgAjpGoaY0JRalS5zm4RQ3SSFSVe vbAkShZdYPeKZ2OIbOciXWA6ZVmfroZUehneVQLmcmnaUk3F+1kG7ctDkkFBmqGP FmeKdsZTnYr5NpalzHawfjYdP4FPWaSS7/uQ/588qPeh+wcfozdSEFtwXVahIcU4 hv9hepTOXe3DKooTkChxTzyPypzZQtpK/dz5L/BbCF+nUTlUN6OR2j7ZKFfg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1728624773; x=1728711173; bh=bAFKi7QxuDDdn5Ffp9cMNlApG+6a z0YdD1+EC6TZ5pM=; b=jNwY0ehUCpBtS+LJg26Jf1YWEFtl1JAQpNuMafg2cRqf sg5L/iWSJZbQo9neGmRtLMJWuo3QdvqU4x4UdCIP4zD1IpW4CY1Wyb7JFMA9TJdG ZM2OObTonTjF6f11eIE7zKletzukkEn0ZXDJ8fzETWyaB561utUSByuwlTwfkNC3 jYqc5wrJkcuT6ufgVwOYWDYV5GR4X6VgDZWxt1AUeVMTIsAS+T1KGRtaVTQcX6lV 2KZhWzU9sfesX71x3jdsSXekMe+yHFVp3SbDw0j4gk82M6ViKIv6ShwG8rOh7hOv 3//oTXGg0VxAIEmnmoJTY3LXXCN14h6+ExxSoDEycA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdefjedgleelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuf fkfhggtggujgesthdtredttddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhh rghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnhepheekfeefgeegvd egvdeffeehtedttdffjeeuffelgffgheefleffleejvdefheeinecuvehluhhsthgvrhfu ihiivgepgeenucfrrghrrghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimhdpnhgspg hrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepghhithesvhhg vghrrdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Fri, 11 Oct 2024 01:32:52 -0400 (EDT) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 7e4f1467 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Fri, 11 Oct 2024 05:31:46 +0000 (UTC) Date: Fri, 11 Oct 2024 07:32:51 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 14/21] combine-diff: fix leaking lost lines Message-ID: <8d305d9b1c8b234f0a029d5db462a0f3bf5b7d12.1728624670.git.ps@pks.im> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: The `cnt` variable tracks the number of lines in a patch diff. It can happen though that there are no newlines, in which case we'd still end up allocating our array of `sline`s. In fact, we always allocate it with `cnt + 2` entries. But when we loop through the array to clear it at the end of this function we only loop until `lno < cnt`, and thus we may not end up releasing whatever the two extra `sline`s contain. Plug this memory leak. Signed-off-by: Patrick Steinhardt --- combine-diff.c | 2 +- t/t4038-diff-combined.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/combine-diff.c b/combine-diff.c index f6b624dc288..3c6d9507fec 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -1220,7 +1220,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent, } free(result); - for (lno = 0; lno < cnt; lno++) { + for (lno = 0; lno < cnt + 2; lno++) { if (sline[lno].lost) { struct lline *ll = sline[lno].lost; while (ll) { diff --git a/t/t4038-diff-combined.sh b/t/t4038-diff-combined.sh index 2ce26e585c9..00190802d83 100755 --- a/t/t4038-diff-combined.sh +++ b/t/t4038-diff-combined.sh @@ -5,6 +5,7 @@ test_description='combined diff' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh . "$TEST_DIRECTORY"/lib-diff.sh From patchwork Fri Oct 11 05:32:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13832074 Received: from fhigh-a7-smtp.messagingengine.com (fhigh-a7-smtp.messagingengine.com [103.168.172.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 23CA7207A03 for ; Fri, 11 Oct 2024 05:32:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.158 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624778; cv=none; b=ck3LsdXhUdQLBOQ1WXNQ/AViiqZY07Bk0QAClBEZFGV28PpeRhpqKKAPahrcXFh3tLC8wSy6NKPQoCt6Mvd/8jV1YR8BKsAiE9f5S/DVtyRZpuqlBQHrhs55G/0wSAls4QPrz1g6AjSgU08YekWrLT7vvQnr0bYK1zWWSNFDdKs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624778; c=relaxed/simple; bh=yaTz0OuvfIZSewtasO5Y0812oJPDC04C0/PZEkT5I5g=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=lYC+qN6kW0TEtmDCEhugPtWiQzVkWETqRGFzxeb/FHHR4hoXcMxKpe9OxjtSDV+aZxPssRkNxTrSOG5+ygGPuAGayT/EJE6UwyX13y5ZZz8FUA5iUYx2NAyfscM2e/dQDgH7i6365Ud3EhdrmeVY2g+P/HNYpnTlOx4QYJjnPPo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=J+csHf8h; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=qKcYPwl4; arc=none smtp.client-ip=103.168.172.158 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="J+csHf8h"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="qKcYPwl4" Received: from phl-compute-12.internal (phl-compute-12.phl.internal [10.202.2.52]) by mailfhigh.phl.internal (Postfix) with ESMTP id 407E011400C4 for ; Fri, 11 Oct 2024 01:32:56 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-12.internal (MEProxy); Fri, 11 Oct 2024 01:32:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1728624776; x=1728711176; bh=MWc6OZvi6N j80bKJ4FI+H/LCdF+lXw3y0fGje5nkQjY=; b=J+csHf8hTHisf0EBWwD7amhFMl 75Vfhlmo6A2oNhRv7eX3g5x/EsSMK2iaWLxZwp5aybLrJHcCQNk34wT50+k41EAQ 4tTmCd7+JP4f2+TWHBkwXcc9SMLtAR7JHlGdBBEW1g7bNjVDpU4AmicMMZ5ONOvn et8ANetjVnzfBseHsYjjpJ+wA3Kj0oXpOjvaJnxI7tPNoZ/gYN6n407U1cU63voP nzeq04lVj022LQbZ2dyjyade/Geffqx/AC7kucyBzD/H/MY3aNmJb8EgFxZfByE8 lQgIaO2jd+tjUfew3NCdqTfuGH9zYsR68F81CnwXIMPGk9dm33wglQrS3lRA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1728624776; x=1728711176; bh=MWc6OZvi6Nj80bKJ4FI+H/LCdF+l Xw3y0fGje5nkQjY=; b=qKcYPwl4NBYCt8v72zyBnvK8TMsOQfpKJoO7Ft1ID2Ch mugDWMlQjav5qT0fyxMJwNQxTkEsYpfaWtcvFWV3hZr4N3uWLFGMMIIq0sO7sFPZ 7pOcrhCtgYMZeaRYOJsVuJKhulrrbyA53cGO3Ltug8MmRxySruxWq0Ki9nQ5I5Va zbXGZUKjEl0hCHWNrh3N7qDMGGF7R6qL6mr5glqyiSIViT8EMCgtjcf75Vsf7zRr 2AIcQVWfHPZxztKNc0gDT0whwDvFisWI4MoIYBx2AeY0qnpQ+S3IiYV1H6BXliXl XHFnuSvC8lVueEu43qMYHIKEQ8YFfnqOCAGVxhWYMQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdefjedgleelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuf fkfhggtggujgesthdtredttddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhh rghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnhepheekfeefgeegvd egvdeffeehtedttdffjeeuffelgffgheefleffleejvdefheeinecuvehluhhsthgvrhfu ihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimhdpnhgspg hrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepghhithesvhhg vghrrdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Fri, 11 Oct 2024 01:32:55 -0400 (EDT) Received: by vm-mail (OpenSMTPD) with ESMTPSA id bb6ad03c (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Fri, 11 Oct 2024 05:31:49 +0000 (UTC) Date: Fri, 11 Oct 2024 07:32:54 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 15/21] dir: release untracked cache data Message-ID: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: There are several cases where we invalidate untracked cache directory entries where we do not free the underlying data, but reset the number of entries. This causes us to leak memory because `free_untracked()` will not iterate over any potential entries which we still had in the array. Fix this issue by freeing old entries. The leak is exposed by t7519, but plugging it alone does not make the whole test suite pass. Signed-off-by: Patrick Steinhardt --- dir.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dir.c b/dir.c index e3ddd5b5296..cb9782fa11f 100644 --- a/dir.c +++ b/dir.c @@ -1056,6 +1056,8 @@ static void do_invalidate_gitignore(struct untracked_cache_dir *dir) { int i; dir->valid = 0; + for (size_t i = 0; i < dir->untracked_nr; i++) + free(dir->untracked[i]); dir->untracked_nr = 0; for (i = 0; i < dir->dirs_nr; i++) do_invalidate_gitignore(dir->dirs[i]); @@ -1083,6 +1085,8 @@ static void invalidate_directory(struct untracked_cache *uc, uc->dir_invalidated++; dir->valid = 0; + for (size_t i = 0; i < dir->untracked_nr; i++) + free(dir->untracked[i]); dir->untracked_nr = 0; for (i = 0; i < dir->dirs_nr; i++) dir->dirs[i]->recurse = 0; @@ -3573,6 +3577,8 @@ static void write_one_dir(struct untracked_cache_dir *untracked, * for safety.. */ if (!untracked->valid) { + for (size_t i = 0; i < untracked->untracked_nr; i++) + free(untracked->untracked[i]); untracked->untracked_nr = 0; untracked->check_only = 0; } @@ -3905,6 +3911,8 @@ static void invalidate_one_directory(struct untracked_cache *uc, { uc->dir_invalidated++; ucd->valid = 0; + for (size_t i = 0; i < ucd->untracked_nr; i++) + free(ucd->untracked[i]); ucd->untracked_nr = 0; } From patchwork Fri Oct 11 05:32:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13832075 Received: from fhigh-a7-smtp.messagingengine.com (fhigh-a7-smtp.messagingengine.com [103.168.172.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C4C25209679 for ; Fri, 11 Oct 2024 05:32:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.158 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624781; cv=none; b=YaJ088HhKw7oWnsMBJ59ArharkiAYs5ajf7tBDqKgK3hv/BdbtmwpxbV2quO+UbzA72pLnMljObuTimwW8awKHjqMhJm2zWTdEHsE7JkgM7o1B8qlKdyH/+/MGAJof0pZYLoP+O6mMuHaa6Zi5Xffh9G2NhJuOJKs2kgD3dyk2g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624781; c=relaxed/simple; bh=UuCFJkPoyxER7iGPRZbJFc8IZ07FKz5kwtZPBD1U2dc=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FkyGRz9/W/EfhLLvtF7y7gsQZIxQzUayI3+ydy6zO9odt3RP2v4LQoy8Qg8aPem70xxoQ3PGke9S8I6UcMwza4FheOKSy3RQS1Q2BoiH3llrQSLnQ2FEP3z2VH9Mc2BgPKnN3raLWEB5E0F4HyPVSuY6thQQaNF/pnskRSqW93A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=J2v5iDwX; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=Gzd0YmKr; arc=none smtp.client-ip=103.168.172.158 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="J2v5iDwX"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Gzd0YmKr" Received: from phl-compute-03.internal (phl-compute-03.phl.internal [10.202.2.43]) by mailfhigh.phl.internal (Postfix) with ESMTP id 1D37811400C4 for ; Fri, 11 Oct 2024 01:32:59 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Fri, 11 Oct 2024 01:32:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1728624779; x=1728711179; bh=NvMn4yIYOQ eHoZTsAWbx/uGMpS8oHLqnnd3k23+pq6Y=; b=J2v5iDwX6CWTEUiLkoy5QUeaqK jUQSQ+elcf3zBd1AUVjv5B25hXvyEa6kQ+GZBOM5ptmhaQiTeMZuxHw8rwNUIMGi IG50fOlS1gxyHrrQpCJ/K0mELtaGrpWwvem58TStXqXul4zvJs9avYtAnCERWRf6 sR7CgzD8Dqn+YtEa4mEActgPYG+rbtrqUGMJcVL8oLVVeF/HNazDsSx1VGfhqDwo oIL8b4VDTcO4y0Dltn61jLfPAWcKkfWcaPzh/EjH5uf+a0yQBxwwWYL0NEo+nzQ4 AFw7JZ5Ey/4EqTZHlr5znXifSLmTyCpzFEosQmlb/swVubeZAXOndC2JadVA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1728624779; x=1728711179; bh=NvMn4yIYOQeHoZTsAWbx/uGMpS8o HLqnnd3k23+pq6Y=; b=Gzd0YmKrSFMGPKr166y3LFEBVAW/S3kvNYMEkggyD0Hq 0NVHNb4YHQIh0DkRgZOFkmcOVbAxT1RmjHgl57agI2jYrwBnzgV4Vv7g0zSWkCTo z3roYwRIZsYTn4+/Q7Z25o5X+oZ5jr9+Zyyb5tFDVlhyvNSEJcAIGcieJaFjatrb uTyJvvqh3LA9E8RFjSuWoA0AFd0u0L/izZg55dyzTHqAVzBcip9/gCfyAJeBTr02 El9PHqRWdbS0ULo/NaSzHNCqkgwEpsZ/4p83b2jpZb0v+cx6uHUdgpgn/hBnZCTE x2JOc0yeVVBcES6897WU2LSHxPQFgbB2U97BdmQsIg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdefjedgleelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuf fkfhggtggujgesthdtredttddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhh rghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnhepheekfeefgeegvd egvdeffeehtedttdffjeeuffelgffgheefleffleejvdefheeinecuvehluhhsthgvrhfu ihiivgepgeenucfrrghrrghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimhdpnhgspg hrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepghhithesvhhg vghrrdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Fri, 11 Oct 2024 01:32:58 -0400 (EDT) Received: by vm-mail (OpenSMTPD) with ESMTPSA id d9ba339c (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Fri, 11 Oct 2024 05:31:52 +0000 (UTC) Date: Fri, 11 Oct 2024 07:32:57 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 16/21] sparse-index: correctly free EWAH contents Message-ID: <170cc61edaa38d3ff76578f2228e855f19b8b8b0.1728624670.git.ps@pks.im> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: While we free the `fsmonitor_dirty` member of `struct index_state`, we do not free the contents of that EWAH. Do so by using `ewah_free()` instead of `FREE_AND_NULL()`. This leak is exposed by t7519, but plugging it alone does not make the test suite pass. Signed-off-by: Patrick Steinhardt --- sparse-index.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sparse-index.c b/sparse-index.c index 3d7f2164e25..2107840bfc5 100644 --- a/sparse-index.c +++ b/sparse-index.c @@ -2,6 +2,7 @@ #include "git-compat-util.h" #include "environment.h" +#include "ewah/ewok.h" #include "gettext.h" #include "name-hash.h" #include "read-cache-ll.h" @@ -242,7 +243,8 @@ int convert_to_sparse(struct index_state *istate, int flags) cache_tree_update(istate, 0); istate->fsmonitor_has_run_once = 0; - FREE_AND_NULL(istate->fsmonitor_dirty); + ewah_free(istate->fsmonitor_dirty); + istate->fsmonitor_dirty = NULL; FREE_AND_NULL(istate->fsmonitor_last_update); istate->sparse_index = INDEX_COLLAPSED; @@ -438,7 +440,8 @@ void expand_index(struct index_state *istate, struct pattern_list *pl) istate->cache_nr = full->cache_nr; istate->cache_alloc = full->cache_alloc; istate->fsmonitor_has_run_once = 0; - FREE_AND_NULL(istate->fsmonitor_dirty); + ewah_free(istate->fsmonitor_dirty); + istate->fsmonitor_dirty = NULL; FREE_AND_NULL(istate->fsmonitor_last_update); strbuf_release(&base); From patchwork Fri Oct 11 05:32:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13832076 Received: from fhigh-a7-smtp.messagingengine.com (fhigh-a7-smtp.messagingengine.com [103.168.172.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E9AA119A285 for ; Fri, 11 Oct 2024 05:33:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.158 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624787; cv=none; b=APxJ/0R4NJv2WJ979pRCy0cWBicP4KuIoqCivjpdxvh4IJ/VS2F4jtDGev880VFh61vrkiupoWXZNeamGTOrEsBGraDcc8lwSGlOq8FBbzDgKiLa/ziax0Mwg9aVP7v0jhwB9JuAF8h0ydsHd6vXfitKy9ZrujKI6Pj3vRbjr5k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624787; c=relaxed/simple; bh=YQH+lqYLyF4IbR4d1QlUUoDWOLIW7BXsyyu+9emWFSs=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=k9tToprDBfyL9+NC68ind7oIUKJMvHbmO29z9cp1jaCBWlUS4YFCB6bv8XAiP7r3DYwI8IyIsZmp+OnaUwMaoPPMyLgI/W2KZpqzXCeRMz4lwpk11FNNqqq3/4eAZ485CogoELAbgxHIOfNmqZautRKFJ3+4r8v9cWBVcWSRmnM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=QVsZCaAE; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=W9QXjhp+; arc=none smtp.client-ip=103.168.172.158 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="QVsZCaAE"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="W9QXjhp+" Received: from phl-compute-08.internal (phl-compute-08.phl.internal [10.202.2.48]) by mailfhigh.phl.internal (Postfix) with ESMTP id EEC211140126 for ; Fri, 11 Oct 2024 01:33:04 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-08.internal (MEProxy); Fri, 11 Oct 2024 01:33:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1728624784; x=1728711184; bh=76+3ktQFP6 30sy/tipwq0PurRyayIZv8BeEVytbj9iI=; b=QVsZCaAE4qIh3Zvlo3CumalMSu DDoCPKC5VSaKfRk2d0b1cpwDRl62W7SCmJkchEC2vq8H18u0ykJtZkBi7JuhJOTR aXDcs+R9FfK1yeAgoFD/uhy3+23d8SybmzFFChKQvOzNHgpJfbsaKMFSnPS4SlJH 802Jwdcx1GYVW0Uv9jhSfMbMNbGa4LulS/MIad9yETimImAp0xx/rOz8n6u38bTz RydIAip4zzE0VrtGLSkLAo4TIUHDScRBKkf1XIa6yLzKWLqUwnoUVYulPMOqyfcT pWxvhsxxkphcgPvnAtprZtMtc3oSYFYGnVkqIMPa7Yr3mqhne7hP11ssb+qw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1728624784; x=1728711184; bh=76+3ktQFP630sy/tipwq0PurRyay IZv8BeEVytbj9iI=; b=W9QXjhp+oY+Hed9jNjMMf2kl0UIXV8ZkXdmixlStMQZu 3dE+R2y2CPqW37KnBCUx2u6dlokRt+M6FuZIke8klvn+fCYaNaWEts1lpZ+MlviM kDq5BzJePii/BM6ivCnEBljgyEEPxaxJjz5fAaqMeuOV5nrPPdaxfxgxUyRDeMJJ BK4wetlJ8nOTPAcSpW/qqZ4omvrWEY4gMI5ixDD1/EfLy0l8YffMoyEGp4eClGGS b0CtLyNKPc1438g/h9Hyd+Iwx0IOQPcNn+tLoexfdrX6vqwKqAlLVTlK6ZPCPz+U 5cU+/A6gb/ZXLZ2TvkQ7Mv5z6IiihMrdzgvhSU3SIA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdefjedgleelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuf fkfhggtggujgesthdtredttddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhh rghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnhepheekfeefgeegvd egvdeffeehtedttdffjeeuffelgffgheefleffleejvdefheeinecuvehluhhsthgvrhfu ihiivgepvdenucfrrghrrghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimhdpnhgspg hrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepghhithesvhhg vghrrdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Fri, 11 Oct 2024 01:33:04 -0400 (EDT) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 6b6bb08b (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Fri, 11 Oct 2024 05:31:57 +0000 (UTC) Date: Fri, 11 Oct 2024 07:32:59 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 17/21] t/helper: stop re-initialization of `the_repository` Message-ID: <8e10ee844c6bcc98f1a848452932408b20244fda.1728624670.git.ps@pks.im> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: While "common-main.c" already initializes `the_repository` for us, we do so a second time in the "read-cache" test helper. This causes a memory leak because the old repository's contents isn't released. Stop calling `initialize_repository()` to plug this leak. Signed-off-by: Patrick Steinhardt --- t/helper/test-read-cache.c | 2 -- t/t7519-status-fsmonitor.sh | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/t/helper/test-read-cache.c b/t/helper/test-read-cache.c index d285c656bd3..e277dde8e71 100644 --- a/t/helper/test-read-cache.c +++ b/t/helper/test-read-cache.c @@ -11,8 +11,6 @@ int cmd__read_cache(int argc, const char **argv) int i, cnt = 1; const char *name = NULL; - initialize_repository(the_repository); - if (argc > 1 && skip_prefix(argv[1], "--print-and-refresh=", &name)) { argc--; argv++; diff --git a/t/t7519-status-fsmonitor.sh b/t/t7519-status-fsmonitor.sh index 7ee69ecdd4a..0f88a58a819 100755 --- a/t/t7519-status-fsmonitor.sh +++ b/t/t7519-status-fsmonitor.sh @@ -2,6 +2,7 @@ test_description='git status with file system watcher' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh # Note, after "git reset --hard HEAD" no extensions exist other than 'TREE' From patchwork Fri Oct 11 05:33:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13832077 Received: from fhigh-a7-smtp.messagingengine.com (fhigh-a7-smtp.messagingengine.com [103.168.172.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B143208983 for ; Fri, 11 Oct 2024 05:33:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.158 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624790; cv=none; b=eQtsbNkKySTVfBPqKwLEQr011ED0MBM9rhWBcZyUZhEBjJ6Dn/glvNmzMaGvwG3c5h+ATorJ7lNAH4vO9kGxLcFGNytT1LvfEvp6swRoQpJ2H5NPWmxRG5RQ8JOv2EWaHnd4XO0lkHwe6ndFg5OFM5PiGSiig07JYy17BM3065c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624790; c=relaxed/simple; bh=yJC1w/xycMqIXIducOqTn3Hsjcbnzx6lmv2R9/ALpkg=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=dMgUcT5b81OdKbRyId/g1Kpkkih4hR54PyG48G9eSH3WRaNGKfM92Wkt9PAWA/yEis3sJopMREMk+4hgfw+HFzh3FrSjAB6oiGPr+21xNo/+fBj8Cf4yjGNcGMu6fK1pNrypHpb1vepjirpBBNRNqRSefNh2rxKrxrUeWdhpGZQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=AZL4OBG3; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=AWaAlkM/; arc=none smtp.client-ip=103.168.172.158 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="AZL4OBG3"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="AWaAlkM/" Received: from phl-compute-08.internal (phl-compute-08.phl.internal [10.202.2.48]) by mailfhigh.phl.internal (Postfix) with ESMTP id D206511400E9 for ; Fri, 11 Oct 2024 01:33:07 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-08.internal (MEProxy); Fri, 11 Oct 2024 01:33:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1728624787; x=1728711187; bh=+k26Sr0L5q DX5MYZuttPVSscffqxxNce/ZnwAcLyhjc=; b=AZL4OBG3479cwJk80Pn81ubliS 6sjAwTSiZhTTFjq2SJ6d8gwI/jGCUfhBrudSx2+q7TTdyE8BpE20uF1zBc3x1V9w L/AiZCeLRlMnxSqYxSsSmZnnZJJviPN8alrRwErh3aImDtZfIOMaOs+5owdvL/Ep P+s+RgWgMaTwK9q45XlHwjmEbghiZs9ImQbYW6HigWDTwFW/txgDHt0t89tLJp6s SK8pmz33eTSq4QNASo+v11QGW/ZlaEJ3X+WvGc8D4vIqS9Xob9d5rAWi2qXE6rE0 AMp1Pz14Rj8awtIUITlo9pFcdAKo2O2Z5EB9UQmMvN+4cJFAyoUtR02nJTHg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1728624787; x=1728711187; bh=+k26Sr0L5qDX5MYZuttPVSscffqx xNce/ZnwAcLyhjc=; b=AWaAlkM/R6ci+STpCs6wi3MrWI4gw7psQDRfjAOb463j ZfUyCwA8xQ8ADgstRJUgBcPLmAt89T5XiDT9IVp3R3nO4hKsa4VmQCdRjUe7UvkK YDD+EfBkcgClPo+xSBIcLFuBDxIBO+NBLJhu/GCa0MCxuyihcNlEM3g3Q/R6a7TR fsDBuvB14Z4u7RHFTXUrXG6Sg4XEmYo2TI3myZ0SUY+GsGxrcTScK+trog/DrbJJ KBjjJGAmPoG8KVq5JROgXSAS3XVQ2pBbOCN9oVEX6lYid8IZ0X69CLR0yZ5tAqno gyJDqEsX3w158f4g4my0VZGsTuzcn1bVj/mpr70faw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdefjedgleelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuf fkfhggtggujgesthdtredttddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhh rghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnhepheekfeefgeegvd egvdeffeehtedttdffjeeuffelgffgheefleffleejvdefheeinecuvehluhhsthgvrhfu ihiivgepfeenucfrrghrrghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimhdpnhgspg hrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepghhithesvhhg vghrrdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Fri, 11 Oct 2024 01:33:07 -0400 (EDT) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 5b2ccd20 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Fri, 11 Oct 2024 05:32:00 +0000 (UTC) Date: Fri, 11 Oct 2024 07:33:05 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 18/21] t/helper: fix leaking buffer in "dump-untracked-cache" Message-ID: <71fd1c76b8a9daa338b2669abe0b7fbe19484abf.1728624670.git.ps@pks.im> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: We never release the local `struct strbuf base` buffer, thus leaking memory. Fix this leak. This leak is exposed by t7063, but plugging it alone does not make the whole test suite pass. Signed-off-by: Patrick Steinhardt --- t/helper/test-dump-untracked-cache.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/t/helper/test-dump-untracked-cache.c b/t/helper/test-dump-untracked-cache.c index 4f010d53249..b2e70837a90 100644 --- a/t/helper/test-dump-untracked-cache.c +++ b/t/helper/test-dump-untracked-cache.c @@ -68,5 +68,7 @@ int cmd__dump_untracked_cache(int ac UNUSED, const char **av UNUSED) printf("flags %08x\n", uc->dir_flags); if (uc->root) dump(uc->root, &base); + + strbuf_release(&base); return 0; } From patchwork Fri Oct 11 05:33:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13832078 Received: from fout-a3-smtp.messagingengine.com (fout-a3-smtp.messagingengine.com [103.168.172.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76EFA209685 for ; Fri, 11 Oct 2024 05:33:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.146 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624792; cv=none; b=Ivs7UEJTohPtv5QqBSMxw+Nqoc0ptB7NGGYnzrnjw/NQseHRDHSeCCRoTkoIgcZt7DSIc5vpCCfNasJIvd1vaTv85MSLtYmlScZbM8TT4p+q+bzoD8jNL1X0ncd1MD2YQzJI5ul7RF8Gg2epJ46i6kKtg2r3ZWB0FPffgbGz1yE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624792; c=relaxed/simple; bh=rgLYx63ZPfp4w3ctEetrXm/FoDM1vQGpLr/1VgTa97Q=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=GoCcIyvfj1/AZYK9N4PCZl1WQum+HFqBQ0IMzDFGA7NFMB7Vcr9ldhKxPA0FP+gYGEqGdRd+ngpLlZOyOBXzms6ryUD7fkDhJZK496OPzlfBoij8WERLhczoN4iYfDmjI3Qnjs6nxEL5ms/9XcUUGWjj1wF8FJLCONLHZ2fnLb8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=lmGuAVwh; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=D0Exe5OC; arc=none smtp.client-ip=103.168.172.146 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="lmGuAVwh"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="D0Exe5OC" Received: from phl-compute-06.internal (phl-compute-06.phl.internal [10.202.2.46]) by mailfout.phl.internal (Postfix) with ESMTP id A5F3C1380198 for ; Fri, 11 Oct 2024 01:33:10 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Fri, 11 Oct 2024 01:33:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1728624790; x=1728711190; bh=076heWZQK1 tkC3KULbM8M0kyY+OFpanYThebcBezQIg=; b=lmGuAVwhn/CHbh28C7NnDRJZ6Q /01vFiQ2lBQ/uidJNULq6WASv1aLpNVBCop8OHdimFAAFaQRku9IzTa9kAvNRMih Tu1bHXR7olO8wFscBRQMlp9l2x1F7AxdA323CSlU0IdwmZEIY3PtPp5aNA4b66Vs GH34G+3Mmf+CMbV0xNT98I2BDAMP/nzpEJlIJk7tO9v1368Y6tHvi6gxPXGOqocW fqwC8KwKf5PP8jNXcDMDgnMt2nszpAXWKrTK5lUUGyGBtm9KsM+Q/syDxoW3o9/X w0CKjf22qkjo/AiYtP97GEAvM3k0ZN4oveR6siZ2q75oEYX1O4ZsGHNfSMzQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1728624790; x=1728711190; bh=076heWZQK1tkC3KULbM8M0kyY+OF panYThebcBezQIg=; b=D0Exe5OCh437Y7hCB4+QR+Url4dZDJo5ipnnUoSFgXZi Pu1PK/Cd9b8GOhvqgq7u6Ors2TXhxXVmRfwjASv4GxmGyJ6/MEIxL5XGJk1wj/WL a3Arrps8wR7vhY3J7l0TPQeW3Jyp3URph31HEfPoxG13WKeoSA1/pILHWzslThLJ Dn8Y6Y4ochzJuR58c764IIKs4ZpCGa/wARmve7wcv0PFOq4gTIFW46RtKnhmzCoU HjMQb7w6/QNZyLsu2+4IK+oWFH+QsgK7Q1pN2VwgoIpfD1pdIjlxBiI12JYUqs++ NipBv/bZIrF96DU/PK41fS1rBE5QYVWl3xPXSANpWw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdefjedgleelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuf fkfhggtggujgesthdtredttddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhh rghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnhepheekfeefgeegvd egvdeffeehtedttdffjeeuffelgffgheefleffleejvdefheeinecuvehluhhsthgvrhfu ihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimhdpnhgspg hrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepghhithesvhhg vghrrdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Fri, 11 Oct 2024 01:33:09 -0400 (EDT) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 1ee76905 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Fri, 11 Oct 2024 05:32:03 +0000 (UTC) Date: Fri, 11 Oct 2024 07:33:07 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 19/21] dir: fix leak when parsing "status.showUntrackedFiles" Message-ID: <8ccc246432da8060b4c3a12d17f6fecebe54dff3.1728624670.git.ps@pks.im> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: We use `repo_config_get_string()` to read "status.showUntrackedFiles" from the config subsystem. This function allocates the result, but we never free the result after parsing it. The value never leaves the scope of the calling function, so refactor it to instead use `repo_config_get_string_tmp()`, which does not hand over ownership to the caller. Signed-off-by: Patrick Steinhardt --- dir.c | 4 ++-- t/t7063-status-untracked-cache.sh | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dir.c b/dir.c index cb9782fa11f..7f35a3e3175 100644 --- a/dir.c +++ b/dir.c @@ -2872,14 +2872,14 @@ static void set_untracked_ident(struct untracked_cache *uc) static unsigned new_untracked_cache_flags(struct index_state *istate) { struct repository *repo = istate->repo; - char *val; + const char *val; /* * This logic is coordinated with the setting of these flags in * wt-status.c#wt_status_collect_untracked(), and the evaluation * of the config setting in commit.c#git_status_config() */ - if (!repo_config_get_string(repo, "status.showuntrackedfiles", &val) && + if (!repo_config_get_string_tmp(repo, "status.showuntrackedfiles", &val) && !strcmp(val, "all")) return 0; diff --git a/t/t7063-status-untracked-cache.sh b/t/t7063-status-untracked-cache.sh index 8929ef481f9..13fea7931cd 100755 --- a/t/t7063-status-untracked-cache.sh +++ b/t/t7063-status-untracked-cache.sh @@ -5,6 +5,7 @@ test_description='test untracked cache' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh # On some filesystems (e.g. FreeBSD's ext2 and ufs) directory mtime From patchwork Fri Oct 11 05:33:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13832079 Received: from fout-a3-smtp.messagingengine.com (fout-a3-smtp.messagingengine.com [103.168.172.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A35E207A3B for ; Fri, 11 Oct 2024 05:33:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.146 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624794; cv=none; b=I/y59KVUtqUxaVcW23Fd95dBDi7jk8rsDkwrne23He689WXm0ucwZtc38KDdJrQhCCcnpowfHb+bxt2bq5ASyQHNNkBK0QWbXV4xd7zwa79zmWfMyyX+dPMEcAON8t8KyY2szvxnsBaXLjvOARxBAY9SVCtOh2CliC4rFusaU6Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624794; c=relaxed/simple; bh=mWLISyo+j9VsKrbFx3SwsFKKiYfSgueM1Oabw3xYfD4=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=F9AUWM3j0FVli7ABKVfJIjdg9NEXmFJOpNnhOQf3IsGHN2yC+kZD3i46OYGmB0z19Z3O93J4ZKHPSFFlcBxq4fnWHwCBmQZMZ+U4UiH0XXYO05FKvIs64jRsSzEJEWxMmI2OoDaSP7S6lbsb/643I/n7VNT5kh0Yy7V/J63Ix6o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=SpGZcf90; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=e9zCqhgE; arc=none smtp.client-ip=103.168.172.146 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="SpGZcf90"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="e9zCqhgE" Received: from phl-compute-10.internal (phl-compute-10.phl.internal [10.202.2.50]) by mailfout.phl.internal (Postfix) with ESMTP id 848E113801AB for ; Fri, 11 Oct 2024 01:33:12 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-10.internal (MEProxy); Fri, 11 Oct 2024 01:33:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1728624792; x=1728711192; bh=/9ClUyhYxz ORLlAs03XNxeJ6b/pQLVmPIXGFMsjTfnE=; b=SpGZcf90GlEAABepITh0TyiYus 0EQghQZhWKpW4bQzw0Bsh3KzptRV25AwapogzKtJymc3/mVL0jVXQGa6uazbLJyk QFnPmINvm9aj/TMD7B3OJDxZ6oTk6aG7ZQb0PweW6Pa+z+8SPr08dJNM7xe66PJB yU/nhzr7jlEG7Jvn3rGUepIO8w+xN1EFn8HWO6PlZqcub+ZP8ZOZSPM3bWcEdQsG nL43DMhZ4IGT+LAbS6rEy0Oi9WbhUMpGtryTKyQFOfIpRDQcbr+UKcUiGoDsiL4P q20csxvdSOuwKHGjF4IW4t5YfEAZEKwhqJGTMo2OSkOigmM44VXh8WS6bNGA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1728624792; x=1728711192; bh=/9ClUyhYxzORLlAs03XNxeJ6b/pQ LVmPIXGFMsjTfnE=; b=e9zCqhgEsSsZcJqUITBb9rKVruc2KyQFls2JAKWyXoeO H2ou+s5kjqdI6wVn6ii8Q8nGGQ0w822qEVH+bpZHtT7XKp9qBoMV7tL6SdeXSsKV eigV7KIzaF73W5Wdmwtbqa/GxM3h+/BUlkv79OjO4oJnPLtvutQCGwUYkpMHy7x9 bI4sAdZEuOPPbjZuw1E1cQrAxMjsFLe+nSGAQfkAUkoiLTL3HVsRh/RWTZFWiM9/ awzfgUAEolTvbLF0+O2KoXV7MEME6rhJ2LL4NTW3kBAguh8IfUt8Ha60zjKvr4pq 93Tl1BL6ny4F+N7fuV7kIDxgT9UKJ7NKlF70cmHqzg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdefjedgleelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuf fkfhggtggujgesthdtredttddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhh rghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnhepheekfeefgeegvd egvdeffeehtedttdffjeeuffelgffgheefleffleejvdefheeinecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimhdpnhgspg hrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepghhithesvhhg vghrrdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Fri, 11 Oct 2024 01:33:11 -0400 (EDT) Received: by vm-mail (OpenSMTPD) with ESMTPSA id c86d3478 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Fri, 11 Oct 2024 05:32:06 +0000 (UTC) Date: Fri, 11 Oct 2024 07:33:10 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 20/21] builtin/merge: release outbut buffer after performing merge Message-ID: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: The `obuf` member of `struct merge_options` is used to buffer output in some cases. In order to not discard its allocated memory we only release its contents in `merge_finalize()` when we're not currently recursing into a subtree. This results in some situations where we seemingly do not release the buffer reliably. We thus have calls to `strbuf_release()` for this buffer scattered across the codebase. But we're missing one callsite in git-merge(1), which causes a memory leak. We should ideally refactor this interface so that callers don't have to know about any such internals. But for now, paper over the issue by adding one more `strbuf_release()` call. Signed-off-by: Patrick Steinhardt --- builtin/merge.c | 1 + t/t6424-merge-unrelated-index-changes.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/builtin/merge.c b/builtin/merge.c index 84d0f3604bc..51038eaca84 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -754,6 +754,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common, clean = merge_recursive(&o, head, remoteheads->item, reversed, &result); free_commit_list(reversed); + strbuf_release(&o.obuf); if (clean < 0) { rollback_lock_file(&lock); diff --git a/t/t6424-merge-unrelated-index-changes.sh b/t/t6424-merge-unrelated-index-changes.sh index 7677c5f08d0..a7ea8acb845 100755 --- a/t/t6424-merge-unrelated-index-changes.sh +++ b/t/t6424-merge-unrelated-index-changes.sh @@ -2,6 +2,7 @@ test_description="merges with unrelated index changes" +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh # Testcase for some simple merges From patchwork Fri Oct 11 05:33:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13832080 Received: from fhigh-a7-smtp.messagingengine.com (fhigh-a7-smtp.messagingengine.com [103.168.172.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 05693209F26 for ; Fri, 11 Oct 2024 05:33:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.158 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624797; cv=none; b=YHh4VqJtqyFrhiegCoGZGkUCCnH6vgVmWiBKttDkxT2OE5bkNcJ5ORhbdl+EonvfBHK7sun/ZB2m6CNZ6awVM1H4HiJezYyMZwCvU5NnPU3FFrDvOo0BDtr0EmXeFF0WdJYBdlmunQBsJt2jYEZXOZw4RHRTFVzJfr2buL2WvCk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728624797; c=relaxed/simple; bh=OEvDcfACMWNiYTfHzZsPsUPELbf3qHVq/aCU7QHSMvA=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=XHE4P+fh1faB65UblHTf9i67hWu266qn0U9zUDbfL6xB3XpzywYYuoOM919zMPUcPlK4WZUFr61RiL2tZ0C8wLvK9QyE9WSOmuPjpUOS8UWcJbsKoHs8NQbPzJejopsMWqglCtqQ8BnuVuS6k4fdxbGL4BtQQ9T3Ad6q1eFIa4s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=ZPtn1Z9Z; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=NCI9nIZp; arc=none smtp.client-ip=103.168.172.158 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="ZPtn1Z9Z"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="NCI9nIZp" Received: from phl-compute-04.internal (phl-compute-04.phl.internal [10.202.2.44]) by mailfhigh.phl.internal (Postfix) with ESMTP id 625F511400C4 for ; Fri, 11 Oct 2024 01:33:15 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Fri, 11 Oct 2024 01:33:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1728624795; x=1728711195; bh=bU96al8XAz r05kZnrtryHWvk8Wuwnp04MUcAVh0RnUQ=; b=ZPtn1Z9ZrTfLnmml183/NVSnCT 28KmCsERv/fmA5OmWfeqU3UXwXJcGAsAapUXJfcVMgYlnoeHpDf24w8pMJVYREH8 EurTgTqr8KQRcpJPvbJ31MWCdf5LObnYcvav9nZfDlJOHMk0vZAiTdG4mZYGUSU5 eBGRyGesCeaZeApK+7lPsP0MgP117xOP17Nxxw06kY47gnYA4lfm3k5xv3h6jdOE dJJZ3JROAG0DrFwvERpWtlIKLyYw9yjC/tzJWoH38Z3cikRjbhhlbdo3/YrCV8Ah HbWaMov2BIRASuQadAV+nP7/IMxsVV+0mB18l/zVLZmoyaye2Rh5AhAH/c/Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1728624795; x=1728711195; bh=bU96al8XAzr05kZnrtryHWvk8Wuw np04MUcAVh0RnUQ=; b=NCI9nIZpiSfUdQ/fH31HoTn18QgE3pkqHKCeKBL3leFG MO/fVsYP/AP3gIkg1yP/haU9XQt3Htf4NtMc/0GNI7SlTPJ/hHD+zVWLh8an+Qh0 Wo/wkt0Tg5MAKkbUblsSSfH+R8+i+diljvbtpXan1qTlTFNgxJHeHCvuNyTY6T10 2R5TixPQh0elKfg5sMEEr71qSPr0YD8R0/TXgQHVcpF+Z+2wxNioRy3DnM78cuhO JKt6ufAV2VmOLN7+j8pD/i+e+pTtN8uAjFQ9LIdgH8+9US0RsdTlujtwt2UjyD3i SrRhVVubColp1RxOeJHWCc3QgODfTDnQqDCN4tFDiA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdefjedgleelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuf fkfhggtggujgesthdtredttddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhh rghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvghrnhepheekfeefgeegvd egvdeffeehtedttdffjeeuffelgffgheefleffleejvdefheeinecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimhdpnhgspg hrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepghhithesvhhg vghrrdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Fri, 11 Oct 2024 01:33:14 -0400 (EDT) Received: by vm-mail (OpenSMTPD) with ESMTPSA id e839673e (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Fri, 11 Oct 2024 05:32:08 +0000 (UTC) Date: Fri, 11 Oct 2024 07:33:13 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 21/21] list-objects-filter-options: work around reported leak on error Message-ID: <6a2baf0d3e538e5f450c45c22248fbc3fefd77af.1728624670.git.ps@pks.im> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: This one is a little bit more curious. In t6112, we have a test that exercises the `git rev-list --filter` option with invalid filters. We execute git-rev-list(1) via `test_must_fail`, which means that we check for leaks even though Git exits with an error code. This causes the following leak: Direct leak of 27 byte(s) in 1 object(s) allocated from: #0 0x5555555e6946 in realloc.part.0 lsan_interceptors.cpp.o #1 0x5555558fb4b6 in xrealloc wrapper.c:137:8 #2 0x5555558b6e06 in strbuf_grow strbuf.c:112:2 #3 0x5555558b7550 in strbuf_add strbuf.c:311:2 #4 0x5555557c1a88 in strbuf_addstr strbuf.h:310:2 #5 0x5555557c1d4c in parse_list_objects_filter list-objects-filter-options.c:261:3 #6 0x555555885ead in handle_revision_pseudo_opt revision.c:2899:3 #7 0x555555884e20 in setup_revisions revision.c:3014:11 #8 0x5555556c4b42 in cmd_rev_list builtin/rev-list.c:588:9 #9 0x5555555ec5e3 in run_builtin git.c:483:11 #10 0x5555555eb1e4 in handle_builtin git.c:749:13 #11 0x5555555ec001 in run_argv git.c:819:4 #12 0x5555555eaf94 in cmd_main git.c:954:19 #13 0x5555556fd569 in main common-main.c:64:11 #14 0x7ffff7ca714d in __libc_start_call_main (.../lib/libc.so.6+0x2a14d) #15 0x7ffff7ca7208 in __libc_start_main@GLIBC_2.2.5 (.../libc.so.6+0x2a208) #16 0x5555555ad064 in _start (git+0x59064) This leak is valid, as we call `die()` and do not clean up the memory at all. But what's curious is that this is the only leak reported, because we don't clean up any other allocated memory, either, and I have no idea why the leak sanitizer treats this buffer specially. In any case, we can work around the leak by shuffling things around a bit. Instead of calling `gently_parse_list_objects_filter()` and dying after we have modified the filter spec, we simply do so beforehand. Like this we don't allocate the buffer in the error case, which makes the reported leak go away. It's not pretty, but it manages to make t6112 leak free. Signed-off-by: Patrick Steinhardt --- list-objects-filter-options.c | 17 +++++++---------- t/t6112-rev-list-filters-objects.sh | 1 + 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/list-objects-filter-options.c b/list-objects-filter-options.c index 00611107d20..fa72e81e4ad 100644 --- a/list-objects-filter-options.c +++ b/list-objects-filter-options.c @@ -252,16 +252,14 @@ void parse_list_objects_filter( const char *arg) { struct strbuf errbuf = STRBUF_INIT; - int parse_error; if (!filter_options->filter_spec.buf) BUG("filter_options not properly initialized"); if (!filter_options->choice) { + if (gently_parse_list_objects_filter(filter_options, arg, &errbuf)) + die("%s", errbuf.buf); strbuf_addstr(&filter_options->filter_spec, arg); - - parse_error = gently_parse_list_objects_filter( - filter_options, arg, &errbuf); } else { struct list_objects_filter_options *sub; @@ -271,18 +269,17 @@ void parse_list_objects_filter( */ transform_to_combine_type(filter_options); - strbuf_addch(&filter_options->filter_spec, '+'); - filter_spec_append_urlencode(filter_options, arg); ALLOC_GROW_BY(filter_options->sub, filter_options->sub_nr, 1, filter_options->sub_alloc); sub = &filter_options->sub[filter_options->sub_nr - 1]; list_objects_filter_init(sub); - parse_error = gently_parse_list_objects_filter(sub, arg, - &errbuf); + if (gently_parse_list_objects_filter(sub, arg, &errbuf)) + die("%s", errbuf.buf); + + strbuf_addch(&filter_options->filter_spec, '+'); + filter_spec_append_urlencode(filter_options, arg); } - if (parse_error) - die("%s", errbuf.buf); } int opt_parse_list_objects_filter(const struct option *opt, diff --git a/t/t6112-rev-list-filters-objects.sh b/t/t6112-rev-list-filters-objects.sh index 0387f35a326..71e38491fa8 100755 --- a/t/t6112-rev-list-filters-objects.sh +++ b/t/t6112-rev-list-filters-objects.sh @@ -5,6 +5,7 @@ test_description='git rev-list using object filtering' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh # Test the blob:none filter.