From patchwork Thu Feb 2 09:52:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13125672 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F06BC05027 for ; Thu, 2 Feb 2023 09:53:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231688AbjBBJxJ (ORCPT ); Thu, 2 Feb 2023 04:53:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231731AbjBBJxF (ORCPT ); Thu, 2 Feb 2023 04:53:05 -0500 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 842626A6F for ; Thu, 2 Feb 2023 01:52:58 -0800 (PST) Received: by mail-wm1-x32d.google.com with SMTP id m5-20020a05600c4f4500b003db03b2559eso891983wmq.5 for ; Thu, 02 Feb 2023 01:52:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SO+30pBuzZsjlM+OyMELwIwiqOcCNLMQDxl5YpIGpOo=; b=HXiYvqEC0JkjIihU/Cml7qqIS/KnjNQAYUBFWMX4cf8U25omaNl9RdgrTWgfAx0K33 2NoN3ACfLi6pcTFsITHsAfKeCvR/NXvQr0f7NVnZqExLQQSYt9WO9NWet3tfYaW1x1hh aGqrpCqz5MWVC8fa92jh5cowzwnOb4xmsnt8DXKWcniZ3EjCH0fqi+SFvSTURt6b6MNT m/DkJpYQSC0YYDLH4JYAn+2cGkwjdYBSY4ruNum2aloFtiYLAM9hv/FY0qMWj5qvHy5+ 82keRRQyNw0g1hcrsxnZWoh2kWyXXJzrr2zjj9QAijAahQ7E101b+7LOVebli3dqQbu6 AYwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SO+30pBuzZsjlM+OyMELwIwiqOcCNLMQDxl5YpIGpOo=; b=3k/uItPUY0IGT9nMW90XyGs70L5h/Lhst193AY1+LIKMV35WWXJwHCLDnQiJHF3dKG 2fGcM8+OG2PdMbukV/6nNlRJQQyBEwaoUY8SKaqqM8l8qd/gzZUvWj//SQ3gWlLgGgcL jN8yXLuhurf054ijDtTPQGc68datT+aA4ubtRdG5Q7xE0jTOfAr4qeESaxvMS9c0evf5 pBfKgHi7UtH0rmR+tj0UOaYssfuvVsHDulF682TlqkNRll0YfmMPQTbSvGuFAHd7G/Op 8WeMXhsivinXxbgLnP6V5nqGDb3bwSMH2juykdU5ZliuVdDzBLHDb8rqDKVZYi8bsasT arGQ== X-Gm-Message-State: AO0yUKWKvxBrXt43lNb2R5nYQlTskd41M1PRJWSI9dR+pRvhox2iJ0ky sj6FtwUjQqFLiztVKUHMsmZlM2AdQakoNzxJ X-Google-Smtp-Source: AK7set+ObDhWoNYODPfgNG/dF80TS0W3jg6+YnrqvbGdh1vhgcG6icIKYZ9qelDXJ3K0ybM7ND6oZg== X-Received: by 2002:a05:600c:3b1e:b0:3dc:4d94:62de with SMTP id m30-20020a05600c3b1e00b003dc4d9462demr5189210wms.14.1675331576448; Thu, 02 Feb 2023 01:52:56 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id i13-20020a1c540d000000b003db03725e86sm4356234wmb.8.2023.02.02.01.52.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 01:52:55 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , Elijah Newren , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v6 01/19] tests: mark tests as passing with SANITIZE=leak Date: Thu, 2 Feb 2023 10:52:32 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1392.g63e6d408230 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When the "ab/various-leak-fixes" topic was merged in [1] only t6021 would fail if the tests were run in the "GIT_TEST_PASSING_SANITIZE_LEAK=check" mode, i.e. to check whether we marked all leak-free tests with "TEST_PASSES_SANITIZE_LEAK=true". Since then we've had various tests starting to pass under SANITIZE=leak. Let's mark those as passing, this is when they started to pass, narrowed down with "git bisect": - t5317-pack-objects-filter-objects.sh: In faebba436e6 (list-objects-filter: plug pattern_list leak, 2022-12-01). - t3210-pack-refs.sh, t5613-info-alternate.sh, t7403-submodule-sync.sh: In 189e97bc4ba (diff: remove parseopts member from struct diff_options, 2022-12-01). - t1408-packed-refs.sh: In ab91f6b7c42 (Merge branch 'rs/diff-parseopts', 2022-12-19). - t0023-crlf-am.sh, t4152-am-subjects.sh, t4254-am-corrupt.sh, t4256-am-format-flowed.sh, t4257-am-interactive.sh, t5403-post-checkout-hook.sh: In a658e881c13 (am: don't pass strvec to apply_parse_options(), 2022-12-13) - t1301-shared-repo.sh, t1302-repo-version.sh: In b07a819c05f (reflog: clear leftovers in reflog_expiry_cleanup(), 2022-12-13). - t1304-default-acl.sh, t1410-reflog.sh, t5330-no-lazy-fetch-with-commit-graph.sh, t5502-quickfetch.sh, t5604-clone-reference.sh, t6014-rev-list-all.sh, t7701-repack-unpack-unreachable.sh: In b0c61be3209 (Merge branch 'rs/reflog-expiry-cleanup', 2022-12-26) - t3800-mktag.sh, t5302-pack-index.sh, t5306-pack-nobase.sh, t5573-pull-verify-signatures.sh, t7612-merge-verify-signatures.sh: In 69bbbe484ba (hash-object: use fsck for object checks, 2023-01-18). - t1451-fsck-buffer.sh: In 8e4309038f0 (fsck: do not assume NUL-termination of buffers, 2023-01-19). - t6501-freshen-objects.sh: In abf2bb895b4 (Merge branch 'jk/hash-object-fsck', 2023-01-30) 1. 9ea1378d046 (Merge branch 'ab/various-leak-fixes', 2022-12-14) Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t0023-crlf-am.sh | 1 + t/t1301-shared-repo.sh | 1 + t/t1302-repo-version.sh | 1 + t/t1304-default-acl.sh | 1 + t/t1408-packed-refs.sh | 1 + t/t1410-reflog.sh | 1 + t/t1451-fsck-buffer.sh | 2 ++ t/t3210-pack-refs.sh | 1 + t/t3800-mktag.sh | 1 + t/t4152-am-subjects.sh | 2 ++ t/t4254-am-corrupt.sh | 2 ++ t/t4256-am-format-flowed.sh | 1 + t/t4257-am-interactive.sh | 2 ++ t/t5302-pack-index.sh | 2 ++ t/t5306-pack-nobase.sh | 2 ++ t/t5317-pack-objects-filter-objects.sh | 1 + t/t5330-no-lazy-fetch-with-commit-graph.sh | 1 + t/t5403-post-checkout-hook.sh | 1 + t/t5502-quickfetch.sh | 1 + t/t5573-pull-verify-signatures.sh | 2 ++ t/t5604-clone-reference.sh | 1 + t/t5613-info-alternate.sh | 2 ++ t/t6014-rev-list-all.sh | 1 + t/t6021-rev-list-exclude-hidden.sh | 1 + t/t6501-freshen-objects.sh | 1 + t/t7403-submodule-sync.sh | 1 + t/t7612-merge-verify-signatures.sh | 1 + t/t7701-repack-unpack-unreachable.sh | 1 + 28 files changed, 36 insertions(+) diff --git a/t/t0023-crlf-am.sh b/t/t0023-crlf-am.sh index f9bbb91f64e..575805513a3 100755 --- a/t/t0023-crlf-am.sh +++ b/t/t0023-crlf-am.sh @@ -2,6 +2,7 @@ test_description='Test am with auto.crlf' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh cat >patchfile <<\EOF diff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh index 58d6da7feb1..1b6437ec079 100755 --- a/t/t1301-shared-repo.sh +++ b/t/t1301-shared-repo.sh @@ -9,6 +9,7 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME TEST_CREATE_REPO_NO_TEMPLATE=1 +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh # Remove a default ACL from the test dir if possible. diff --git a/t/t1302-repo-version.sh b/t/t1302-repo-version.sh index 7cf80bf66a6..70389fa2ebb 100755 --- a/t/t1302-repo-version.sh +++ b/t/t1302-repo-version.sh @@ -5,6 +5,7 @@ test_description='Test repository version check' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'setup' ' diff --git a/t/t1304-default-acl.sh b/t/t1304-default-acl.sh index c69ae41306c..31b89dd9693 100755 --- a/t/t1304-default-acl.sh +++ b/t/t1304-default-acl.sh @@ -9,6 +9,7 @@ test_description='Test repository with default ACL' # => this must come before . ./test-lib.sh umask 077 +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh # We need an arbitrary other user give permission to using ACLs. root diff --git a/t/t1408-packed-refs.sh b/t/t1408-packed-refs.sh index 41ba1f1d7fc..9469c79a585 100755 --- a/t/t1408-packed-refs.sh +++ b/t/t1408-packed-refs.sh @@ -5,6 +5,7 @@ test_description='packed-refs entries are covered by loose refs' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success setup ' diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh index aa59954f6c5..6c45965b1e4 100755 --- a/t/t1410-reflog.sh +++ b/t/t1410-reflog.sh @@ -7,6 +7,7 @@ test_description='Test prune and reflog expiration' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh check_have () { diff --git a/t/t1451-fsck-buffer.sh b/t/t1451-fsck-buffer.sh index 9ac270abab6..3413da40e4a 100755 --- a/t/t1451-fsck-buffer.sh +++ b/t/t1451-fsck-buffer.sh @@ -14,6 +14,8 @@ so. These tests _might_ catch such overruns in normal use, but should be run with ASan or valgrind for more confidence. ' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh # the general idea for tags and commits is to build up the "base" file diff --git a/t/t3210-pack-refs.sh b/t/t3210-pack-refs.sh index 577f32dc71f..07a0ff93def 100755 --- a/t/t3210-pack-refs.sh +++ b/t/t3210-pack-refs.sh @@ -12,6 +12,7 @@ semantic is still the same. GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'enable reflogs' ' diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh index e3cf0ffbe59..d3e428ff46e 100755 --- a/t/t3800-mktag.sh +++ b/t/t3800-mktag.sh @@ -4,6 +4,7 @@ test_description='git mktag: tag object verify test' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh ########################################################### diff --git a/t/t4152-am-subjects.sh b/t/t4152-am-subjects.sh index 4c68245acad..9f2edba1f83 100755 --- a/t/t4152-am-subjects.sh +++ b/t/t4152-am-subjects.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='test subject preservation with format-patch | am' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh make_patches() { diff --git a/t/t4254-am-corrupt.sh b/t/t4254-am-corrupt.sh index 54be7da1611..45f1d4f95e5 100755 --- a/t/t4254-am-corrupt.sh +++ b/t/t4254-am-corrupt.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='git am with corrupt input' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh make_mbox_with_nul () { diff --git a/t/t4256-am-format-flowed.sh b/t/t4256-am-format-flowed.sh index 2369c4e17ad..1015273bc82 100755 --- a/t/t4256-am-format-flowed.sh +++ b/t/t4256-am-format-flowed.sh @@ -2,6 +2,7 @@ test_description='test format=flowed support of git am' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'setup' ' diff --git a/t/t4257-am-interactive.sh b/t/t4257-am-interactive.sh index aed8f4de3d6..f26d7fd2dbd 100755 --- a/t/t4257-am-interactive.sh +++ b/t/t4257-am-interactive.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='am --interactive tests' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'set up patches to apply' ' diff --git a/t/t5302-pack-index.sh b/t/t5302-pack-index.sh index 59e9e77223b..f89809be53c 100755 --- a/t/t5302-pack-index.sh +++ b/t/t5302-pack-index.sh @@ -4,6 +4,8 @@ # test_description='pack index with 64-bit offsets and object CRC' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'setup' ' diff --git a/t/t5306-pack-nobase.sh b/t/t5306-pack-nobase.sh index 51973f4a512..846c5ca7d34 100755 --- a/t/t5306-pack-nobase.sh +++ b/t/t5306-pack-nobase.sh @@ -6,6 +6,8 @@ test_description='git-pack-object with missing base ' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh # Create A-B chain diff --git a/t/t5317-pack-objects-filter-objects.sh b/t/t5317-pack-objects-filter-objects.sh index 5b707d911b5..b26d476c646 100755 --- a/t/t5317-pack-objects-filter-objects.sh +++ b/t/t5317-pack-objects-filter-objects.sh @@ -5,6 +5,7 @@ test_description='git pack-objects 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 blob:none filter. diff --git a/t/t5330-no-lazy-fetch-with-commit-graph.sh b/t/t5330-no-lazy-fetch-with-commit-graph.sh index 2cc7fd7a476..5eb28f0512d 100755 --- a/t/t5330-no-lazy-fetch-with-commit-graph.sh +++ b/t/t5330-no-lazy-fetch-with-commit-graph.sh @@ -2,6 +2,7 @@ test_description='test for no lazy fetch with the commit-graph' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'setup: prepare a repository with a commit' ' diff --git a/t/t5403-post-checkout-hook.sh b/t/t5403-post-checkout-hook.sh index 978f240cdac..cfaae547398 100755 --- a/t/t5403-post-checkout-hook.sh +++ b/t/t5403-post-checkout-hook.sh @@ -7,6 +7,7 @@ test_description='Test the post-checkout hook.' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success setup ' diff --git a/t/t5502-quickfetch.sh b/t/t5502-quickfetch.sh index b160f8b7fb7..7b3ff21b984 100755 --- a/t/t5502-quickfetch.sh +++ b/t/t5502-quickfetch.sh @@ -5,6 +5,7 @@ test_description='test quickfetch from local' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success setup ' diff --git a/t/t5573-pull-verify-signatures.sh b/t/t5573-pull-verify-signatures.sh index a53dd8550d0..1221ac05978 100755 --- a/t/t5573-pull-verify-signatures.sh +++ b/t/t5573-pull-verify-signatures.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='pull signature verification tests' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh . "$TEST_DIRECTORY/lib-gpg.sh" diff --git a/t/t5604-clone-reference.sh b/t/t5604-clone-reference.sh index 2734e37e880..dc86dea1333 100755 --- a/t/t5604-clone-reference.sh +++ b/t/t5604-clone-reference.sh @@ -7,6 +7,7 @@ test_description='test clone --reference' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh base_dir=$(pwd) diff --git a/t/t5613-info-alternate.sh b/t/t5613-info-alternate.sh index 895f46bb911..7708cbafa98 100755 --- a/t/t5613-info-alternate.sh +++ b/t/t5613-info-alternate.sh @@ -4,6 +4,8 @@ # test_description='test transitive info/alternate entries' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'preparing first repository' ' diff --git a/t/t6014-rev-list-all.sh b/t/t6014-rev-list-all.sh index c9bedd29cba..16b8bd1d090 100755 --- a/t/t6014-rev-list-all.sh +++ b/t/t6014-rev-list-all.sh @@ -2,6 +2,7 @@ test_description='--all includes detached HEADs' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh diff --git a/t/t6021-rev-list-exclude-hidden.sh b/t/t6021-rev-list-exclude-hidden.sh index 32b2b094138..11c50b7c0dd 100755 --- a/t/t6021-rev-list-exclude-hidden.sh +++ b/t/t6021-rev-list-exclude-hidden.sh @@ -2,6 +2,7 @@ test_description='git rev-list --exclude-hidden test' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'setup' ' diff --git a/t/t6501-freshen-objects.sh b/t/t6501-freshen-objects.sh index 10662456aee..3968b47ed53 100755 --- a/t/t6501-freshen-objects.sh +++ b/t/t6501-freshen-objects.sh @@ -28,6 +28,7 @@ test_description='check pruning of dependent objects' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh # We care about reachability, so we do not want to use diff --git a/t/t7403-submodule-sync.sh b/t/t7403-submodule-sync.sh index ea92ef52a5e..ff09443a0a4 100755 --- a/t/t7403-submodule-sync.sh +++ b/t/t7403-submodule-sync.sh @@ -11,6 +11,7 @@ These tests exercise the "git submodule sync" subcommand. GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success setup ' diff --git a/t/t7612-merge-verify-signatures.sh b/t/t7612-merge-verify-signatures.sh index 61330f71b17..f5c90cc22a1 100755 --- a/t/t7612-merge-verify-signatures.sh +++ b/t/t7612-merge-verify-signatures.sh @@ -4,6 +4,7 @@ test_description='merge signature verification 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/t7701-repack-unpack-unreachable.sh b/t/t7701-repack-unpack-unreachable.sh index b7ac4f598a8..ebb267855fe 100755 --- a/t/t7701-repack-unpack-unreachable.sh +++ b/t/t7701-repack-unpack-unreachable.sh @@ -5,6 +5,7 @@ test_description='git repack works correctly' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh fsha1= From patchwork Thu Feb 2 09:52:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13125674 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF22EC636D4 for ; Thu, 2 Feb 2023 09:53:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232054AbjBBJxP (ORCPT ); Thu, 2 Feb 2023 04:53:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232002AbjBBJxG (ORCPT ); Thu, 2 Feb 2023 04:53:06 -0500 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57CD376BE for ; Thu, 2 Feb 2023 01:52:59 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id bg26so949513wmb.0 for ; Thu, 02 Feb 2023 01:52:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=adgCct04pNckz7JaSPhGY6S1ptijQH5JMhfdAkwEWEQ=; b=VpCW1pyTzO3jXitiGg6Sb3CIYmvOOmevrilnICULit0I2QN42IS5WWX33vAxQsOYHx VE3Q3mqCi+iUQ21xNm6ZDjPOJRIgw06Rgwb4O3/Zk/R0eNKT2NBGiSCNfvUawXW4KsYW EE1U2Ydye9ZvoQWkenk1HB+qh0OxmaVF63rBiYNRsoIIXrPCRAVleedusQ+Ry2jFRub/ tb4FR9cypzdRanTWLiJf3KvhII4cVAU9SV7vHdiVVy3wnBUUpV5DedDfZlp/fN0sag3L XNIAB10q14+qmDKqVcLu0itxtzladDz4NJbZ5J2nZarEtvZ6OWmpBm+mPFf7gsGQGqKA sEEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=adgCct04pNckz7JaSPhGY6S1ptijQH5JMhfdAkwEWEQ=; b=Cw58cj2edEbHQEVcWManXfDPSgTP1MVUgLm6ZSz7wz/8qeIBFfInJWQEnux1IH7AaU zheB9rC3fnj/39SgM+URcMbnzi3hDQXeodUoBrkR95JtJ/2Tub8wqB+8QjO6TuAlidoD rSjM36cNeEU0sUAYkNqZiVj2xTAizcgn31DZcfhRueTAFK7vqVovbPyKv/UbRajvGyM1 nu0BdI2ETUivd3usoejlkKEIuFNn21mGxz1AsBN25lOcCq2zlyCU58NJCKkCsmmk/4mh Qu0fyC5qhZjbhny3BISWQCq2utvEN8MC2NaagjvMeFrr08YNyrgPXQFtQmur87yQYYpy AZJA== X-Gm-Message-State: AO0yUKXxdZzvYonmb1N7GNrxQHn3lJNi2EBFTWpaDggPAwQwUBlHTK01 IYXm2tXL5+/KLeAq2tyVPm8q27T3xDHXAv1H X-Google-Smtp-Source: AK7set/0h1L/5luZPOi2QE860zmRWBJHuj6YzXd9+yhu0/p8SP0A7EJUbjKi4HiEtii6szyB0SjVUg== X-Received: by 2002:a05:600c:4448:b0:3da:107e:a1e6 with SMTP id v8-20020a05600c444800b003da107ea1e6mr5186944wmn.17.1675331577482; Thu, 02 Feb 2023 01:52:57 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id i13-20020a1c540d000000b003db03725e86sm4356234wmb.8.2023.02.02.01.52.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 01:52:56 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , Elijah Newren , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v6 02/19] bundle.c: don't leak the "args" in the "struct child_process" Date: Thu, 2 Feb 2023 10:52:33 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1392.g63e6d408230 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Fix a leak that's been here since 7366096de9d (bundle API: change "flags" to be "extra_index_pack_args", 2021-09-05). If we can't verify the bundle, we didn't call child_process_clear() to clear the "args". But rather than adding an additional child_process_clear() call, let's verify the bundle before we start preparing the process we're going to spawn. If we fail to verify, we don't need to push anything to the child_process "args". Helped-by: Elijah Newren Signed-off-by: Ævar Arnfjörð Bjarmason --- bundle.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bundle.c b/bundle.c index 4ef7256aa11..9ebb10a8f72 100644 --- a/bundle.c +++ b/bundle.c @@ -627,6 +627,10 @@ int unbundle(struct repository *r, struct bundle_header *header, enum verify_bundle_flags flags) { struct child_process ip = CHILD_PROCESS_INIT; + + if (verify_bundle(r, header, flags)) + return -1; + strvec_pushl(&ip.args, "index-pack", "--fix-thin", "--stdin", NULL); /* If there is a filter, then we need to create the promisor pack. */ @@ -638,8 +642,6 @@ int unbundle(struct repository *r, struct bundle_header *header, strvec_clear(extra_index_pack_args); } - if (verify_bundle(r, header, flags)) - return -1; ip.in = bundle_fd; ip.no_stdout = 1; ip.git_cmd = 1; From patchwork Thu Feb 2 09:52:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13125673 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6ABC8C05027 for ; Thu, 2 Feb 2023 09:53:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232011AbjBBJxM (ORCPT ); Thu, 2 Feb 2023 04:53:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232007AbjBBJxG (ORCPT ); Thu, 2 Feb 2023 04:53:06 -0500 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C62D9039 for ; Thu, 2 Feb 2023 01:53:00 -0800 (PST) Received: by mail-wm1-x32b.google.com with SMTP id c4-20020a1c3504000000b003d9e2f72093so3289620wma.1 for ; Thu, 02 Feb 2023 01:53:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=F4TEZEiX6R0VS5kl1AYrgTkik40WretknH+ZEUFqHK0=; b=UFCvTXUVN5p83QwnABr1wAwkEyNLh2pFoKrjCIZXj4V4clTPeVetD8bZsKS1tudnEY pdDDUcv0oLwMe/q0YvOcml/u3dCg1xmJORRAnQB0eU5ZtwML7KrQynf/l6LVXP6wHMsB dTwcd8waryZwy4qeoxF2x7RAq74bbckfaTbJWDHuIzVrnaEs7K/Rp85wJSA5Cvrj2djQ Ez9JD+0jZHKAqOIx2Fswh9UofJpxcKcPj1AEMADimJoQuO366eXi9sIloYB31sBDMaem 4OPUj6SW90a6ulTbvigAwGJHlbiUSZu2KeFxmb1WwKCivJvaFy9dycbVtVqyfBH47Pus 0ubg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=F4TEZEiX6R0VS5kl1AYrgTkik40WretknH+ZEUFqHK0=; b=XECbjcFQn220DAwHpjuVOAPau/Tn/+JxHoN+3LwWhcxlkawgjWh0R/do0gST/jTUTS LgfplW4ZZJ3KFan9/U+HN1r8DHyxTiNocA36GtkkVQidp67fLPQB07yGmczKhIX8+6eE ALiOx+sPhW8aPSsyLppajWgvn+K48HbeGUqq0HyOM1VtlJIQF9Huk7Z+vRv81m1emMwU BMxOvGhMVngSrnLbdL4C/jHIvS+nr1LBpuQChnrdQyoiUdCl/VFUPtLOFSChE88o6PyA lPRRZpoRamplUI5Ia9tHJ3rYc6vbSVZsy7d8PTeoa31qlsHH5GcsuPzdhZ+D0DSBmUpS vqkw== X-Gm-Message-State: AO0yUKVjWJ7EtAEf3/xY9sDGKikDLHVPXKwNrRxbHP43R8lVJmdPa1Q9 wByDA8QSjbdUrvbH0H/kydH3mxf4CXwfKaUl X-Google-Smtp-Source: AK7set/OhrGZLNqKlbn8bNk2m9YXwcYlyeyLP5d8btUKJAjrCEIObKnH0fn561fYwi4/ZExTPNR0kg== X-Received: by 2002:a7b:ce15:0:b0:3d9:f769:2115 with SMTP id m21-20020a7bce15000000b003d9f7692115mr5266232wmc.26.1675331578552; Thu, 02 Feb 2023 01:52:58 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id i13-20020a1c540d000000b003db03725e86sm4356234wmb.8.2023.02.02.01.52.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 01:52:57 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , Elijah Newren , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v6 03/19] commit-graph: use free_commit_graph() instead of UNLEAK() Date: Thu, 2 Feb 2023 10:52:34 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1392.g63e6d408230 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In 0bfb48e6723 (builtin/commit-graph.c: UNLEAK variables, 2018-10-03) this was made to UNLEAK(), but we can just as easily invoke the free_commit_graph() function added in c3756d5b7fc (commit-graph: add free_commit_graph, 2018-07-11) instead. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/commit-graph.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c index e8f77f535f3..0102ac8540e 100644 --- a/builtin/commit-graph.c +++ b/builtin/commit-graph.c @@ -67,6 +67,7 @@ static int graph_verify(int argc, const char **argv, const char *prefix) int fd; struct stat st; int flags = 0; + int ret; static struct option builtin_commit_graph_verify_options[] = { OPT_BOOL(0, "shallow", &opts.shallow, @@ -111,8 +112,9 @@ static int graph_verify(int argc, const char **argv, const char *prefix) if (!graph) return !!open_ok; - UNLEAK(graph); - return verify_commit_graph(the_repository, graph, flags); + ret = verify_commit_graph(the_repository, graph, flags); + free_commit_graph(graph); + return ret; } extern int read_replace_refs; From patchwork Thu Feb 2 09:52:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13125675 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19485C61DA4 for ; Thu, 2 Feb 2023 09:53:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232096AbjBBJxQ (ORCPT ); Thu, 2 Feb 2023 04:53:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232022AbjBBJxH (ORCPT ); Thu, 2 Feb 2023 04:53:07 -0500 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C982859E5 for ; Thu, 2 Feb 2023 01:53:01 -0800 (PST) Received: by mail-wm1-x32c.google.com with SMTP id bg26so949614wmb.0 for ; Thu, 02 Feb 2023 01:53:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LOtckYi8qxV59qg3momEzfXfGro8Sqx42RrYuErg3SY=; b=UephVU5IfxITva7Zys9/ZAw+lSuC0Pl3XAy6qp0hkJAVC45ZnBFNdAvg4O0xdanWhv IkcsOBLD9/EF05l/FvmwX8c1XdT6GZQDTukkWesc3fhJTA5FSREIpxgGLedyPbWlxWXk ajYxrdjM6ptcGjH3OaNtJ9+irzaX3eihrr+ZVL1IyiGdwJaZJARfhTj8vlQ6bhOe6Cod TesftkUPt4dVZrpNyf+kNEAAITIIyI5bwi4/1LgjW0MVjHgBp+HaNfq9JJyS06mKkm2N 19l89gar+swCmZxry7qsHxjWcdeLjaidbV1V0eusnJJWTSrEVsRoY1/nW3SMhvWZbdQK sTiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LOtckYi8qxV59qg3momEzfXfGro8Sqx42RrYuErg3SY=; b=bJ0Gn/2+qeNMpRhO10nEg1lhnebJdyrjbZCtAZjk1ALxyaNdR/QFQVBonjqctAC2Ir t05ikdOefscJxrIn5FuHmCSS2dmD+vMab9YAnIMqH/CP5sSsTWpKRGKmuHXn2VAtGCea iodnPvGBtIBr8QToshqH5Leju1cM9/H7/bWfC8cG3eCMAEtruqb2iOf1+OryBs70vsI7 oJEZWNNoO/BweFBfdUOR6EhcLUV5SXrjZugKtOhceJga1GmvtOwXhRYYv/7WIonu6RyS a3euGJstJHuRdE5GCl/JEKN4FxuroxGDA07+jyUQ1DV/jcmzLjySBYy/jMn+Cizw93mn RbCQ== X-Gm-Message-State: AO0yUKXof5/g0p1rn/lBLB5H7Xb2F68ZNn7dKUnAIsE1EVxmc9sQ15RS Ltgif8NAbJ0jALlQjkkb/fNVo2itP7rhRvfc X-Google-Smtp-Source: AK7set+hg9IOkzyooT3SK4KhS9L/Jfz7fQEs8rg5u4nC045h8TI/TrtxscOsMQ8YJxFdLz19/ipQMw== X-Received: by 2002:a05:600c:1f10:b0:3dc:4356:533c with SMTP id bd16-20020a05600c1f1000b003dc4356533cmr5194736wmb.5.1675331579613; Thu, 02 Feb 2023 01:52:59 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id i13-20020a1c540d000000b003db03725e86sm4356234wmb.8.2023.02.02.01.52.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 01:52:58 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , Elijah Newren , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v6 04/19] clone: use free() instead of UNLEAK() Date: Thu, 2 Feb 2023 10:52:35 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1392.g63e6d408230 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change an UNLEAK() added in 0c4542738e6 (clone: free or UNLEAK further pointers when finished, 2021-03-14) to use a "to_free" pattern instead. In this case the "repo" can be either this absolute_pathdup() value, or in the "else if" branch seen in the context the the "argv[0]" argument to "main()". We can only free() the value in the former case, hence the "to_free" pattern. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/clone.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/builtin/clone.c b/builtin/clone.c index 5453ba5277f..ba82f5e4108 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -892,6 +892,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix) int is_bundle = 0, is_local; int reject_shallow = 0; const char *repo_name, *repo, *work_tree, *git_dir; + char *repo_to_free = NULL; char *path = NULL, *dir, *display_repo = NULL; int dest_exists, real_dest_exists = 0; const struct ref *refs, *remote_head; @@ -949,7 +950,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix) path = get_repo_path(repo_name, &is_bundle); if (path) { FREE_AND_NULL(path); - repo = absolute_pathdup(repo_name); + repo = repo_to_free = absolute_pathdup(repo_name); } else if (strchr(repo_name, ':')) { repo = repo_name; display_repo = transport_anonymize_url(repo); @@ -1413,7 +1414,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix) free(unborn_head); free(dir); free(path); - UNLEAK(repo); + free(repo_to_free); junk_mode = JUNK_LEAVE_ALL; transport_ls_refs_options_release(&transport_ls_refs_options); From patchwork Thu Feb 2 09:52:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13125677 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74DDBC05027 for ; Thu, 2 Feb 2023 09:53:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232039AbjBBJxc (ORCPT ); Thu, 2 Feb 2023 04:53:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231731AbjBBJxL (ORCPT ); Thu, 2 Feb 2023 04:53:11 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 362F514EAE for ; Thu, 2 Feb 2023 01:53:02 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id t6-20020a1c7706000000b003dfdaa1d998so596715wmi.0 for ; Thu, 02 Feb 2023 01:53:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=M8NiGbk/wdupI/c45k1udDd3FWnBg8iQ0e/U1eHNtz8=; b=WCQh5nZAm2zh0q7O5KnFpELI2xbh8Z2IXTVOpnYXLkkfIFqYtFoMWqiscwE0wt7Fg6 IjMIwhrqQRSQKiN+GLZv9ly01jpwvJxcDZnvVmuPsDAHJDA0myXkL+1e3IIw3mCGqtmU Psec49bb6Zn0aDDqaGEcIUAQCpMP9rUIVfuTPBj5dc/XoYhoyqXrX1VdiWvFxXrMTjSc DZTbWv1skvLsNmBT1UvABklYSV9UKntkgO8Dky6O9lWunx8Tboirt45et+lkwvmN08u8 k0Aw/fJbB030Ju3ySTl8BtDgV6jpAsIYt5DHXlRJnZ7RADyA47Ppk1fWTyvbb3Sxjyev 3/6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=M8NiGbk/wdupI/c45k1udDd3FWnBg8iQ0e/U1eHNtz8=; b=cjdPy0k3MMlp2h/WZSdRfacFD+tCfGbWLYqVWj7pGBzFr32Zi6RoVeoX3uONHcO1y/ lhc9PHFb5p8gxv+Evjikf7eblta3OedDx2mUecXIKPg6E30tJ8Kwj1XgUk25/l0f73cI LJMp9gvcubrl1v2ZGajJMq97f8CgEGKJgCs9fQVCgh5Jm6YhaPDZ9Zt03dYC2Yzvtz+V FJBtswYdm+Mg0Ee6lQmx+p8xmnZrmb93lTEba3le60cz5xNkErrK711OmD7NldOBQQer 9Smhq1i1nc8zLORCs8hm1wEbOkJDHrxrwKA1ORNm60USDoMrjbajGyNJ/H8ZtOhpUkjz vuww== X-Gm-Message-State: AO0yUKVEtNow3580c5jWvHNXbhcpQZ/rV4NnrCdlmdm6drs/U7wHVD9G JPkHGTBgn/meJE+MKXoeFRvCn6hsSjuk4txg X-Google-Smtp-Source: AK7set/XJHz7vkT03da1trXO1SiprrWAoNWThu96+ws2KlatDMcWBSR5uoG+9u5Q8UMXofFLAl1lEg== X-Received: by 2002:a05:600c:314d:b0:3dc:5bd7:62ec with SMTP id h13-20020a05600c314d00b003dc5bd762ecmr5044501wmo.32.1675331581037; Thu, 02 Feb 2023 01:53:01 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id i13-20020a1c540d000000b003db03725e86sm4356234wmb.8.2023.02.02.01.52.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 01:52:59 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , Elijah Newren , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v6 05/19] various: add missing clear_pathspec(), fix leaks Date: Thu, 2 Feb 2023 10:52:36 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1392.g63e6d408230 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Fix memory leaks resulting from a missing clear_pathspec(). - archive.c: Plug a leak in the "struct archiver_args", and clear_pathspec() the "pathspec" member that the "parse_pathspec_arg()" call in this function populates. - builtin/clean.c: Fix a memory leak that's been with us since 893d839970c (clean: convert to use parse_pathspec, 2013-07-14). - builtin/reset.c: Add clear_pathspec() calls to cmd_reset(), including to the codepaths where we'd return early. - builtin/stash.c: Call clear_pathspec() on the pathspec initialized in push_stash(). Signed-off-by: Ævar Arnfjörð Bjarmason --- archive.c | 1 + builtin/clean.c | 1 + builtin/reset.c | 11 ++++++++--- builtin/stash.c | 7 +++++-- t/t5001-archive-attr.sh | 1 + t/t5004-archive-corner-cases.sh | 2 ++ t/t7105-reset-patch.sh | 2 ++ t/t7106-reset-unborn-branch.sh | 2 ++ t/t7107-reset-pathspec-file.sh | 1 + t/t7301-clean-interactive.sh | 1 + 10 files changed, 24 insertions(+), 5 deletions(-) diff --git a/archive.c b/archive.c index 81ff76fce99..f2a8756d84f 100644 --- a/archive.c +++ b/archive.c @@ -710,6 +710,7 @@ int write_archive(int argc, const char **argv, const char *prefix, string_list_clear_func(&args.extra_files, extra_file_info_clear); free(args.refname); + clear_pathspec(&args.pathspec); return rc; } diff --git a/builtin/clean.c b/builtin/clean.c index b2701a28158..b15eab328b7 100644 --- a/builtin/clean.c +++ b/builtin/clean.c @@ -1092,5 +1092,6 @@ int cmd_clean(int argc, const char **argv, const char *prefix) strbuf_release(&buf); string_list_clear(&del_list, 0); string_list_clear(&exclude_list, 0); + clear_pathspec(&pathspec); return (errors != 0); } diff --git a/builtin/reset.c b/builtin/reset.c index fea20a9ba0b..e9c10618cd3 100644 --- a/builtin/reset.c +++ b/builtin/reset.c @@ -390,7 +390,8 @@ int cmd_reset(int argc, const char **argv, const char *prefix) if (reset_type != NONE) die(_("options '%s' and '%s' cannot be used together"), "--patch", "--{hard,mixed,soft}"); trace2_cmd_mode("patch-interactive"); - return run_add_interactive(rev, "--patch=reset", &pathspec); + update_ref_status = run_add_interactive(rev, "--patch=reset", &pathspec); + goto cleanup; } /* git reset tree [--] paths... can be used to @@ -439,8 +440,10 @@ int cmd_reset(int argc, const char **argv, const char *prefix) LOCK_DIE_ON_ERROR); if (reset_type == MIXED) { int flags = quiet ? REFRESH_QUIET : REFRESH_IN_PORCELAIN; - if (read_from_tree(&pathspec, &oid, intent_to_add)) - return 1; + if (read_from_tree(&pathspec, &oid, intent_to_add)) { + update_ref_status = 1; + goto cleanup; + } the_index.updated_skipworktree = 1; if (!no_refresh && get_git_work_tree()) { uint64_t t_begin, t_delta_in_ms; @@ -488,5 +491,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix) discard_index(&the_index); +cleanup: + clear_pathspec(&pathspec); return update_ref_status; } diff --git a/builtin/stash.c b/builtin/stash.c index 839569a9803..71a4ee6b1a5 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -1727,6 +1727,7 @@ static int push_stash(int argc, const char **argv, const char *prefix, OPT_PATHSPEC_FILE_NUL(&pathspec_file_nul), OPT_END() }; + int ret; if (argc) { force_assume = !strcmp(argv[0], "-p"); @@ -1766,8 +1767,10 @@ static int push_stash(int argc, const char **argv, const char *prefix, die(_("the option '%s' requires '%s'"), "--pathspec-file-nul", "--pathspec-from-file"); } - return do_push_stash(&ps, stash_msg, quiet, keep_index, patch_mode, - include_untracked, only_staged); + ret = do_push_stash(&ps, stash_msg, quiet, keep_index, patch_mode, + include_untracked, only_staged); + clear_pathspec(&ps); + return ret; } static int push_stash_unassumed(int argc, const char **argv, const char *prefix) diff --git a/t/t5001-archive-attr.sh b/t/t5001-archive-attr.sh index 2f6eef5e372..04d300eeda7 100755 --- a/t/t5001-archive-attr.sh +++ b/t/t5001-archive-attr.sh @@ -3,6 +3,7 @@ test_description='git archive attribute tests' TEST_CREATE_REPO_NO_TEMPLATE=1 +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh SUBSTFORMAT='%H (%h)%n' diff --git a/t/t5004-archive-corner-cases.sh b/t/t5004-archive-corner-cases.sh index ae508e21623..9f2c6da80e8 100755 --- a/t/t5004-archive-corner-cases.sh +++ b/t/t5004-archive-corner-cases.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='test corner cases of git-archive' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh # the 10knuls.tar file is used to test for an empty git generated tar diff --git a/t/t7105-reset-patch.sh b/t/t7105-reset-patch.sh index fc2a6cf5c7a..9b46da7aaa7 100755 --- a/t/t7105-reset-patch.sh +++ b/t/t7105-reset-patch.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='git reset --patch' + +TEST_PASSES_SANITIZE_LEAK=true . ./lib-patch-mode.sh test_expect_success PERL 'setup' ' diff --git a/t/t7106-reset-unborn-branch.sh b/t/t7106-reset-unborn-branch.sh index ecb85c3b823..a0b67a0b843 100755 --- a/t/t7106-reset-unborn-branch.sh +++ b/t/t7106-reset-unborn-branch.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='git reset should work on unborn branch' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'setup' ' diff --git a/t/t7107-reset-pathspec-file.sh b/t/t7107-reset-pathspec-file.sh index 523efbecde1..af5ea406db3 100755 --- a/t/t7107-reset-pathspec-file.sh +++ b/t/t7107-reset-pathspec-file.sh @@ -2,6 +2,7 @@ test_description='reset --pathspec-from-file' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_tick diff --git a/t/t7301-clean-interactive.sh b/t/t7301-clean-interactive.sh index a07e8b86de2..d82a3210a1d 100755 --- a/t/t7301-clean-interactive.sh +++ b/t/t7301-clean-interactive.sh @@ -2,6 +2,7 @@ test_description='git clean -i basic tests' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh . "$TEST_DIRECTORY"/lib-terminal.sh From patchwork Thu Feb 2 09:52:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13125682 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1CA15C636D4 for ; Thu, 2 Feb 2023 09:53:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232315AbjBBJxx (ORCPT ); Thu, 2 Feb 2023 04:53:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232217AbjBBJx2 (ORCPT ); Thu, 2 Feb 2023 04:53:28 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3546B144B3 for ; Thu, 2 Feb 2023 01:53:04 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id c10-20020a05600c0a4a00b003db0636ff84so927952wmq.0 for ; Thu, 02 Feb 2023 01:53:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yDKL2c4jS4+lyhZLRjZx+DSWhTIiOWwZzSEkYPeD5ic=; b=ih0n7sfVOLaOyYANiFtFAC7LSlpCEGXs7bsEChBjd4MCcz3fdOIWTVs87Zk2w4S3rX LY+jKbBJ/v/iZrj2pn4OqjDhogqDnoDTl/oyLtbEjkEis9WNkgnpodbpIVt331ZqaYQ3 7657bzY/cmQ6zRMSyYMRjsuVglQ6PC5kKNKNgJDz7Jn/RfS8kEwgSUH4nPW98lceyn3d g1sOCFJM5LS+vD/LZZ0Qab1oidbuddd1aZmzaOlXmz1R9aT3zdcVa6ysa4Dt/Bzi1z5O sDLZFRuax5Es2e98+uPMRObYam6FtRuAORm9Y32l5Un+PE6G66yacEkfBh/3mRU3Hbqg UKQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yDKL2c4jS4+lyhZLRjZx+DSWhTIiOWwZzSEkYPeD5ic=; b=Tdtpl/g9NvS1L4WGwK/nuCRdwhAgp0Pyn/+5SSqlTZfPGUEx+jiBF8yxWcNTLcQ7cl +vzhC+FTZjPXumdcOMIyyIspePqJrsPG1Un2vyGmB3mszxoTD31ExPMHg6LLV7aq+uc0 4qroC0TO7/fB7DEhrOdiQ2F9O/FZqS5lpJkGgKOR6beNvHFshbDvYFtVwE2g1NQEnmO2 1eX40Zf4ZXgEqiWOsf81vIARaqiFGGK3h2mcXQLcZQhKBySiBF0OGMZH47hEYPhYksBD 4yk11iKPaFi2QYIKeTO7g13x6/5+arY4noaGRqAbF5dc9qLKGqf2pu2sSyForqr0s2rD PHoQ== X-Gm-Message-State: AO0yUKUlO/+cbShJoN1AOJTcOYfTBtOfAR8QWpeYXJY9qGTq68hwktwq K27h+8y1IoUPtpCl3+0/oa3YSvtNW+tRQnCC X-Google-Smtp-Source: AK7set9N8dor4g+/9JcC9msh+xRRl7zMZhxrXuk03gsYIHt6KPDxLo13nSZW78LP22mLpIFmL8QxWQ== X-Received: by 2002:a05:600c:35d6:b0:3db:a3a:4594 with SMTP id r22-20020a05600c35d600b003db0a3a4594mr5824239wmq.28.1675331582147; Thu, 02 Feb 2023 01:53:02 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id i13-20020a1c540d000000b003db03725e86sm4356234wmb.8.2023.02.02.01.53.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 01:53:01 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , Elijah Newren , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v6 06/19] name-rev: don't xstrdup() an already dup'd string Date: Thu, 2 Feb 2023 10:52:37 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1392.g63e6d408230 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When "add_to_tip_table()" is called with a non-zero "shorten_unambiguous" we always return an xstrdup()'d string, which we'd then xstrdup() again, leaking memory. See [1] and [2] for how this leak came about. We could xstrdup() only if "shorten_unambiguous" wasn't true, but let's instead inline this code, so that information on whether we need to xstrdup() is contained within add_to_tip_table(). 1. 98c5c4ad015 (name-rev: allow to specify a subpath for --refs option, 2013-06-18) 2. b23e0b9353e (name-rev: allow converting the exact object name at the tip of a ref, 2013-07-07) Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/name-rev.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/builtin/name-rev.c b/builtin/name-rev.c index 15535e914a6..49fae523694 100644 --- a/builtin/name-rev.c +++ b/builtin/name-rev.c @@ -273,17 +273,6 @@ static int subpath_matches(const char *path, const char *filter) return -1; } -static const char *name_ref_abbrev(const char *refname, int shorten_unambiguous) -{ - if (shorten_unambiguous) - refname = shorten_unambiguous_ref(refname, 0); - else if (skip_prefix(refname, "refs/heads/", &refname)) - ; /* refname already advanced */ - else - skip_prefix(refname, "refs/", &refname); - return refname; -} - struct name_ref_data { int tags_only; int name_only; @@ -309,11 +298,19 @@ static void add_to_tip_table(const struct object_id *oid, const char *refname, int shorten_unambiguous, struct commit *commit, timestamp_t taggerdate, int from_tag, int deref) { - refname = name_ref_abbrev(refname, shorten_unambiguous); + char *short_refname = NULL; + + if (shorten_unambiguous) + short_refname = shorten_unambiguous_ref(refname, 0); + else if (skip_prefix(refname, "refs/heads/", &refname)) + ; /* refname already advanced */ + else + skip_prefix(refname, "refs/", &refname); ALLOC_GROW(tip_table.table, tip_table.nr + 1, tip_table.alloc); oidcpy(&tip_table.table[tip_table.nr].oid, oid); - tip_table.table[tip_table.nr].refname = xstrdup(refname); + tip_table.table[tip_table.nr].refname = short_refname ? + short_refname : xstrdup(refname); tip_table.table[tip_table.nr].commit = commit; tip_table.table[tip_table.nr].taggerdate = taggerdate; tip_table.table[tip_table.nr].from_tag = from_tag; From patchwork Thu Feb 2 09:52:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13125678 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E46AC61DA4 for ; Thu, 2 Feb 2023 09:53:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229929AbjBBJxe (ORCPT ); Thu, 2 Feb 2023 04:53:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232022AbjBBJx0 (ORCPT ); Thu, 2 Feb 2023 04:53:26 -0500 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34A2976BE for ; Thu, 2 Feb 2023 01:53:05 -0800 (PST) Received: by mail-wm1-x336.google.com with SMTP id c10-20020a05600c0a4a00b003db0636ff84so927986wmq.0 for ; Thu, 02 Feb 2023 01:53:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=frzWfRJpJ0O1aFO/GRUiQuCxmVwilh+adMvWOTqAKL8=; b=QOEo6eiZTUTjrpm2Hyny/q/2Fv/hCfK3AVzpR2Is3xwCIh6M5HeVylUx6CRITIzrsK 90DAyBMJX8j1nYstCpTmQIgZfRQNhstJPaiHLwjs90VWBNEP9UJ5b23lNKwI+ogtFWwb u/b6Zx30O/MxqXF7BcVqBbhDiTy9FI+R0Y771rFYvY2TQ6nWW24wh7vKs+mnqNvSMoPp m4Xa2AvvqTEtRykHfUW5aPB2cLt85JvFnd2A3yjg1LV52GgEbQJP9UxfXjDCa5/KktXB 67884pstA9RHLTsAcol7KT195AXYmSxDYtX6jYNlIWYJDK7yehVMnh9W4y6Wjn8waw+R KmDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=frzWfRJpJ0O1aFO/GRUiQuCxmVwilh+adMvWOTqAKL8=; b=x2vmGjCcMMQnn8hc7do+msZrAg8wIJOmt/oNDUHb4xL7oTpMNkli13KiiYOrzIWQWl MoUP8dlPWofK7GI8maFrB6i688hHBvKDK+9pAeYA84CcloTQJXAjj5LqU4r+SIjEr7gE NtjsWoSSKduoW7L6wXLbMyd98MsMNm7P+gT/fOhjS2Pen9QTk/1z0VzMILIR42L+YP6g fbYeKqWUR/eKIpVnGTwnXjr9AjygVEELx6vascMpv3SW5zvBzKquE1H5eoAXeVQmf30R X5bRzz/YF09jptiXnVTr0zxCOmNk9yo+72x1D3S+vlYY5QH3ycCgWiRIMSKslexNQG73 9A9Q== X-Gm-Message-State: AO0yUKUGTTzU1/7+4KWKH9HFHlxqyVrIk4Nvq8nzsfisOY+Y8ZUpsy1D sPcsnMa56Y0eKaVhnkyw0bq/kvZ964EM+Qa3 X-Google-Smtp-Source: AK7set+ajWRpCDprZL9wd4JFpGRmq2vPBzfsIuErBWoobWf6Dpjif1m2vJ4OgzY9KUS8e6Nx5I3/4w== X-Received: by 2002:a1c:f211:0:b0:3db:8de:6993 with SMTP id s17-20020a1cf211000000b003db08de6993mr1399415wmc.4.1675331583604; Thu, 02 Feb 2023 01:53:03 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id i13-20020a1c540d000000b003db03725e86sm4356234wmb.8.2023.02.02.01.53.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 01:53:02 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , Elijah Newren , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v6 07/19] repack: fix leaks on error with "goto cleanup" Date: Thu, 2 Feb 2023 10:52:38 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1392.g63e6d408230 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In cmd_repack() when we hit an error, replace "return ret" with "goto cleanup" to ensure we free the necessary data structures. Helped-by: Elijah Newren Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/repack.c | 13 +++++++------ t/t5312-prune-corruption.sh | 1 + t/t6011-rev-list-with-bad-commit.sh | 1 + 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/builtin/repack.c b/builtin/repack.c index c1402ad038f..f6493795318 100644 --- a/builtin/repack.c +++ b/builtin/repack.c @@ -948,7 +948,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix) ret = start_command(&cmd); if (ret) - return ret; + goto cleanup; if (geometry) { FILE *in = xfdopen(cmd.in, "w"); @@ -977,7 +977,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix) fclose(out); ret = finish_command(&cmd); if (ret) - return ret; + goto cleanup; if (!names.nr && !po_args.quiet) printf_ln(_("Nothing new to pack.")); @@ -1007,7 +1007,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix) &existing_nonkept_packs, &existing_kept_packs); if (ret) - return ret; + goto cleanup; if (delete_redundant && expire_to) { /* @@ -1039,7 +1039,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix) &existing_nonkept_packs, &existing_kept_packs); if (ret) - return ret; + goto cleanup; } } @@ -1115,7 +1115,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix) string_list_clear(&include, 0); if (ret) - return ret; + goto cleanup; } reprepare_packed_git(the_repository); @@ -1172,10 +1172,11 @@ int cmd_repack(int argc, const char **argv, const char *prefix) write_midx_file(get_object_directory(), NULL, NULL, flags); } +cleanup: string_list_clear(&names, 1); string_list_clear(&existing_nonkept_packs, 0); string_list_clear(&existing_kept_packs, 0); clear_pack_geometry(geometry); - return 0; + return ret; } diff --git a/t/t5312-prune-corruption.sh b/t/t5312-prune-corruption.sh index 9d8e249ae8b..230cb387122 100755 --- a/t/t5312-prune-corruption.sh +++ b/t/t5312-prune-corruption.sh @@ -14,6 +14,7 @@ what currently happens. If that changes, these tests should be revisited. GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'disable reflogs' ' diff --git a/t/t6011-rev-list-with-bad-commit.sh b/t/t6011-rev-list-with-bad-commit.sh index bad02cf5b83..b2e422cf0f7 100755 --- a/t/t6011-rev-list-with-bad-commit.sh +++ b/t/t6011-rev-list-with-bad-commit.sh @@ -2,6 +2,7 @@ test_description='git rev-list should notice bad commits' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh # Note: From patchwork Thu Feb 2 09:52:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13125676 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 559B9C61DA4 for ; Thu, 2 Feb 2023 09:53:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231520AbjBBJx3 (ORCPT ); Thu, 2 Feb 2023 04:53:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231646AbjBBJxL (ORCPT ); Thu, 2 Feb 2023 04:53:11 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3677215552 for ; Thu, 2 Feb 2023 01:53:06 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id n13so918202wmr.4 for ; Thu, 02 Feb 2023 01:53:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=17Rlx901S0kqKb8WfSVS1uJY7ZdJnravOGWVxGkcUmE=; b=dpwf1jl4nLgtL5gfzlltCP5yaXLTrcgxzik3Yt7zl7pyEdEo9lXlcSCK03DgkUxSFO O2ZMakhh8op+oXI0CvRrJHR9jAkyv8HYSt+tXHWeI3E3YSsSwbnLaEyxEcEPVac3idc0 XBkeTy4DZjOoCW5Dl7hH00KnJsIH520BfTTU3Rx3m+C+2UMzOFbWISH0Ny8DvmvG/5s2 BoReDbhEPUBuRFocu8GxsW91KqlIQitfMpIRjL45HbWiqTTkEXlFpDyN+FsqeNw1np5D sakMsetfS6w4cqD/rYP2FBDhOZQw/OK7wbyfpAttIuy8M8jgujiFwhrO0FeTglBXFatC tbeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=17Rlx901S0kqKb8WfSVS1uJY7ZdJnravOGWVxGkcUmE=; b=rrpGZTid14UZwBrv7XA+Iv9mmAfGws3RHJ+Ifw7ETHxFPfl9y0VbHvWeVfmNZ0Qzuw O6SCE6q7aPDZW9fu341w+5W9YyzZfLJZSRRasjEReDQZ4UkaD5RZ7GXVklkpW1tzLaR5 lImuXEoYh6jQegXl8GsvmWojAkqwK5e0BVfcipHugv4Rm+F9m6/h7ZMJ6ArBGNaSiJuw RbePd9Ytbr0m+tsTDqXMAQASwyS4jsObqNvhBvHfgmy4zUZHZ0/NWB5WK5e+FhtLYrLB 6Q+0Zf49+r0DxIic2eTxLJ2ImS9EH4+Oy54wW/uvoWcxC0jLMVawzvI/cCluuDXJlf6m 9P/A== X-Gm-Message-State: AO0yUKXm2DHX3qVm2dbD3BCuIS1UoXi0E73Fw95EtU5gYwE2bIiBRLQ1 scKOWnb+eiq/E1a7z5e8XK/AawzYh3qr12Jm X-Google-Smtp-Source: AK7set+H97PCIyp7v1phKETiNumAnz23zMxPfN+anKAIlTOYtyCx8AanhLaWxiuoVZTmIEaHrQtKGA== X-Received: by 2002:a1c:4c12:0:b0:3dc:16d4:a99f with SMTP id z18-20020a1c4c12000000b003dc16d4a99fmr5223593wmf.8.1675331584849; Thu, 02 Feb 2023 01:53:04 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id i13-20020a1c540d000000b003db03725e86sm4356234wmb.8.2023.02.02.01.53.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 01:53:04 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , Elijah Newren , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v6 08/19] worktree: fix a trivial leak in prune_worktrees() Date: Thu, 2 Feb 2023 10:52:39 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1392.g63e6d408230 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org We were leaking both the "struct strbuf" in prune_worktrees(), as well as the "path" we got from should_prune_worktree(). Since these were the only two uses of the "struct string_list" let's change it to a "DUP" and push these to it with "string_list_append_nodup()". For the string_list_append_nodup() we could also string_list_append() the main_path.buf, and then strbuf_release(&main_path) right away. But doing it this way avoids an allocation, as we already have the "struct strbuf" prepared for appending to "kept". Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/worktree.c | 6 +++--- t/t2401-worktree-prune.sh | 1 + t/t2406-worktree-repair.sh | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/builtin/worktree.c b/builtin/worktree.c index f51c40f1e1e..254283aa6f5 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -173,7 +173,7 @@ static void prune_worktrees(void) { struct strbuf reason = STRBUF_INIT; struct strbuf main_path = STRBUF_INIT; - struct string_list kept = STRING_LIST_INIT_NODUP; + struct string_list kept = STRING_LIST_INIT_DUP; DIR *dir = opendir(git_path("worktrees")); struct dirent *d; if (!dir) @@ -184,14 +184,14 @@ static void prune_worktrees(void) if (should_prune_worktree(d->d_name, &reason, &path, expire)) prune_worktree(d->d_name, reason.buf); else if (path) - string_list_append(&kept, path)->util = xstrdup(d->d_name); + string_list_append_nodup(&kept, path)->util = xstrdup(d->d_name); } closedir(dir); strbuf_add_absolute_path(&main_path, get_git_common_dir()); /* massage main worktree absolute path to match 'gitdir' content */ strbuf_strip_suffix(&main_path, "/."); - string_list_append(&kept, strbuf_detach(&main_path, NULL)); + string_list_append_nodup(&kept, strbuf_detach(&main_path, NULL)); prune_dups(&kept); string_list_clear(&kept, 1); diff --git a/t/t2401-worktree-prune.sh b/t/t2401-worktree-prune.sh index 3d28c7f06b2..568a47ec426 100755 --- a/t/t2401-worktree-prune.sh +++ b/t/t2401-worktree-prune.sh @@ -5,6 +5,7 @@ test_description='prune $GIT_DIR/worktrees' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success initialize ' diff --git a/t/t2406-worktree-repair.sh b/t/t2406-worktree-repair.sh index 5c44453e1c1..8970780efcc 100755 --- a/t/t2406-worktree-repair.sh +++ b/t/t2406-worktree-repair.sh @@ -2,6 +2,7 @@ test_description='test git worktree repair' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success setup ' From patchwork Thu Feb 2 09:52:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13125679 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABBAAC05027 for ; Thu, 2 Feb 2023 09:53:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232470AbjBBJxs (ORCPT ); Thu, 2 Feb 2023 04:53:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231715AbjBBJx2 (ORCPT ); Thu, 2 Feb 2023 04:53:28 -0500 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36B5A15C97 for ; Thu, 2 Feb 2023 01:53:07 -0800 (PST) Received: by mail-wm1-x332.google.com with SMTP id n28-20020a05600c3b9c00b003ddca7a2bcbso898937wms.3 for ; Thu, 02 Feb 2023 01:53:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6BRz6X9PHYgefLRa/6Sx1Su7ZnsBell+RWhr9HOZec8=; b=Z2d2HgXY5Hn0S8iqi/O3Z1nJi8UFEw3h1AiEuxfRzR/N1Bery4Wf6KzPJyP49j5Zfn 4lXsaW+8pBFQkYIH7UycAJLvOnWuv66nLWe/AAb/LO8KcURAjilVgNnAWIEk9iwYRnAn 1cTiODHUG0C48q0EFEhePhqXdFzkXuaJA5VUpXBZ2SgLLmRhL+vRIF+c3+m70jTNDbBp GO8nnvA/KkeVozm6lWcq1zvhfWtDGL+WcSOP0gkynComBe0o8stkpwqXvLZf+LzHzObY rqyaIlOJAQTnF/bq5wAwqLPHwheNyqC3EOgCpkQS1Jxv+S8rCtDcPs0I9KHcAs5wTnTk yxGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6BRz6X9PHYgefLRa/6Sx1Su7ZnsBell+RWhr9HOZec8=; b=fk082oKSV1XESsGJ+SxHxxEilf/PnljbwxaTO09EsmixeIBWytFrRvBFVFPnRuB0jZ eMYiONB85VtGbNtkVbVVU1ibkIEGcyXjN/pDYZ2pObufBybr2YVXU9TPgeZXz7e2UY63 RPxVeXGHPguvgyZogztgADW7CDNf7Dz/m9iSPB4HMJ6PNhWUd7mQ4MgcxZkItzOiCq69 oOlKK4dKzkVwrmV87pjejLUI6ihekY2E1Gf5EDyXJVj/dMJ67i5Z5lec8+6+Ag6KhSc9 tXyk89XufYJ0MCrryn8EWUeVafDQLVH6DQjJ0MpJ7wIol4GolK2TNeNfpDrhtgT15Ugp d3Dg== X-Gm-Message-State: AO0yUKVskAa82wUAs/2gS+ykG1LJ21QdfXQgRweZ48Uey6a6n7ECb1Ll hF2NyHDqDe5/1vW3gjhUxroEk5ursbKkDFPN X-Google-Smtp-Source: AK7set8jd/yF+yaxJsX6EdL4aGYgc3BKbVFp9qRocNrLGhXpc81O7htEBPZYVLuWyiVmyyg8b+YUHw== X-Received: by 2002:a05:600c:1d86:b0:3da:1f6a:7b36 with SMTP id p6-20020a05600c1d8600b003da1f6a7b36mr5732752wms.0.1675331585829; Thu, 02 Feb 2023 01:53:05 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id i13-20020a1c540d000000b003db03725e86sm4356234wmb.8.2023.02.02.01.53.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 01:53:05 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , Elijah Newren , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v6 09/19] http-backend.c: fix "dir" and "cmd_arg" leaks in cmd_main() Date: Thu, 2 Feb 2023 10:52:40 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1392.g63e6d408230 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Free the "dir" variable after we're done with it. Before 917adc03608 (http-backend: add GIT_PROJECT_ROOT environment var, 2009-10-30) there was no leak here, as we'd get it via getenv(), but since 917adc03608 we've xstrdup()'d it (or the equivalent), so we need to free() it. We also need to free the "cmd_arg" variable, which has been leaked ever since it was added in 2f4038ab337 (Git-aware CGI to provide dumb HTTP transport, 2009-10-30). Signed-off-by: Ævar Arnfjörð Bjarmason --- http-backend.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/http-backend.c b/http-backend.c index 6eb3b2fe51c..67819d931ce 100644 --- a/http-backend.c +++ b/http-backend.c @@ -786,6 +786,7 @@ int cmd_main(int argc, const char **argv) if (!getenv("GIT_HTTP_EXPORT_ALL") && access("git-daemon-export-ok", F_OK) ) not_found(&hdr, "Repository not exported: '%s'", dir); + free(dir); http_config(); max_request_buffer = git_env_ulong("GIT_HTTP_MAX_REQUEST_BUFFER", @@ -795,5 +796,6 @@ int cmd_main(int argc, const char **argv) setenv(GIT_PROTOCOL_ENVIRONMENT, proto_header, 0); cmd->imp(&hdr, cmd_arg); + free(cmd_arg); return 0; } From patchwork Thu Feb 2 09:52:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13125681 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4161C05027 for ; Thu, 2 Feb 2023 09:53:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232112AbjBBJxv (ORCPT ); Thu, 2 Feb 2023 04:53:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232176AbjBBJx2 (ORCPT ); Thu, 2 Feb 2023 04:53:28 -0500 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B46C19020 for ; Thu, 2 Feb 2023 01:53:08 -0800 (PST) Received: by mail-wm1-x32d.google.com with SMTP id q8so916232wmo.5 for ; Thu, 02 Feb 2023 01:53:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=B+1xeIHH8e7VVPp3ZkirbCrLXngWO5KqVCVyQVH9ayE=; b=TZO6m9jYZQieprzLn80kIaAmeH1XFulQA6mLsMFP42WfN0mzLXGFMa/HwU1P8D5pxR yWV6rsBCFL8zF5lfzl78deXVEhMIrNNDSj3gifloydc0HJdmfD6/Dgg9Ajyv+6kWLQec jQkZwyFVoehGBfQE9Us8djRwa5ju0s0UUkZNA7BipAJ15FjaHkbLcdL8R4rw13MSPX8G P+KieO3xgLaPCim38tI5dYKgVvZXCRyShKzFRuGCr608qUC2Oo38ro1SRHgSO7g6KX6r u9HVW4NT/sMQO7OKRK3InywUHwmfeBAdrAdUgyw1tYcO4xLJuCYmXM//QI9rbj16HPp8 5ihw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=B+1xeIHH8e7VVPp3ZkirbCrLXngWO5KqVCVyQVH9ayE=; b=Xqgqu4BxvYIqcN/tve4NfIsIBZiNcGalIJxY+YHEZFPpNZ0MWtMQhp9aEv5ofB8f8B MYi7ytywVyzHtaG0bTzhAP6HeReGlUSWBaR8lL9PdJiwtoFH0wSWMbAWSJRCkGf+jTbE FO1v8+/MyqbNd+UyBqJ4bWzoHxE4KjSIDiKY07zGuEaKrP9zwJGE+t7dbRZxOMrmS4H8 a6BmftrFueXGf8LogIgrTIyBip6Ki8l9fNnzR+9QAPkdQghxBMsvEezC0om0lLbJB7He Sdgwm4RO+WHJWKAP+yUME4XhmLLJ7yIoDIvU9G2xt8JzXj/WUgkjaYRXT4rXJ93IwLfk 2PAQ== X-Gm-Message-State: AO0yUKWwKGeoOP8hvQsn1MoBuf4uezfafmnrA/AJtR+i8GVmOPWQQlfi AwEARfDM5h+bY/cVQ7CavbMJtQiSjlH4qvM3 X-Google-Smtp-Source: AK7set/bOidD/TdSHnq61icj6cgGpM9ub2KNvZMI0DMnoQxYMBNvjl0TD+7qKj2O2zr3HrgqiZ15ow== X-Received: by 2002:a05:600c:2109:b0:3df:d86d:797a with SMTP id u9-20020a05600c210900b003dfd86d797amr1737455wml.25.1675331586869; Thu, 02 Feb 2023 01:53:06 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id i13-20020a1c540d000000b003db03725e86sm4356234wmb.8.2023.02.02.01.53.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 01:53:06 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , Elijah Newren , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v6 10/19] http-backend.c: fix cmd_main() memory leak, refactor reg{exec,free}() Date: Thu, 2 Feb 2023 10:52:41 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1392.g63e6d408230 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Fix a memory leak that's been with us ever since 2f4038ab337 (Git-aware CGI to provide dumb HTTP transport, 2009-10-30). In this case we're not calling regerror() after a failed regexec(), and don't otherwise use "re" afterwards. We can therefore simplify this code by calling regfree() right after the regexec(). An alternative fix would be to add a regfree() to both the "return" and "break" path in this for-loop. Signed-off-by: Ævar Arnfjörð Bjarmason --- http-backend.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/http-backend.c b/http-backend.c index 67819d931ce..8ab58e55f85 100644 --- a/http-backend.c +++ b/http-backend.c @@ -759,10 +759,14 @@ int cmd_main(int argc, const char **argv) struct service_cmd *c = &services[i]; regex_t re; regmatch_t out[1]; + int ret; if (regcomp(&re, c->pattern, REG_EXTENDED)) die("Bogus regex in service table: %s", c->pattern); - if (!regexec(&re, dir, 1, out, 0)) { + ret = regexec(&re, dir, 1, out, 0); + regfree(&re); + + if (!ret) { size_t n; if (strcmp(method, c->method)) @@ -774,7 +778,6 @@ int cmd_main(int argc, const char **argv) dir[out[0].rm_so] = 0; break; } - regfree(&re); } if (!cmd) From patchwork Thu Feb 2 09:52:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13125680 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AACFCC61DA4 for ; Thu, 2 Feb 2023 09:53:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232606AbjBBJxu (ORCPT ); Thu, 2 Feb 2023 04:53:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232112AbjBBJx2 (ORCPT ); Thu, 2 Feb 2023 04:53:28 -0500 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B46478A7D for ; Thu, 2 Feb 2023 01:53:08 -0800 (PST) Received: by mail-wm1-x32d.google.com with SMTP id m5-20020a05600c4f4500b003db03b2559eso892400wmq.5 for ; Thu, 02 Feb 2023 01:53:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Cy408xK5SnIuhFLEcKXEl0w1IcVRfyBxKJsx3W6yrRs=; b=Dvq5tc5BJ6n5TbaLqnPt42+/38jWnKLNZapBWA7NNqli21BRWxWnJVsej/fbw6NSKx lPCRZTB91UL6Gq9oJfJXVbs8JHZz/PKjytbh4u5xuwAwnxiUA08aIAmY+N7z1TNATGhP uwQyDy/vJTnBh6OEGhhLWo7ZjCSxJKDKl/UbG3SgFXijaKRlZ11p5z0VR8XyLlyGcMVm 4maRn+bmSKJlgQkXaRzRIy7AKWZbzyox1cu8qw5CgqOa9IUwNwNMn54ECaz0U1ow5dQQ Sld+QWumlE8NJ3KalBiBnAZUxT1aBIoeI7WzQbg++ykIrxBpaRShvM2Zs2fv0BcETesM M+Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Cy408xK5SnIuhFLEcKXEl0w1IcVRfyBxKJsx3W6yrRs=; b=N+UavKy2vMAZ99Ggh8JM6FeFrzbWtDHJ5EKyCLCLke0RghQThYISjquhRBe7cqQmTu LUrHKEP+kbEnHLmlBk6trJpuobs5cuK1YI84HFmk/0X9lUJks+SKGqZoz14pUyI6EVeY QCCKeJmdsm0/GzRM4L9gRVlUTJyGyqrWlPNJB1bwptG/258I7dINHbiSbvJCeL9BsvQL 4fj70I547Z0JoDy3Soq+6gAhbb+jNWWs345EN+j4N2XGY2QbpuzeF1TFbQZ4RpVsG8W5 E8NwVOpP4uw/28L8UQuFWw1lwi2vNMuE7ufjrYXVsB3Bv2Sadmn/zgbX4hR64J4FhgGl UAiw== X-Gm-Message-State: AO0yUKUMHVJja2kcC1aHtkgiW1M4voLn+haWfnu60ujeY3t336NJDZBq DKVfHvUyjmI7wD0KOoCytjyeXyN8Ohevz1ci X-Google-Smtp-Source: AK7set98WifiH0siTeXSnQf3ejnEPnAvkqzKVfxw38Iupcd4Wvpg04tsB70Wq3+h/QZfOu0JdSGiPA== X-Received: by 2002:a05:600c:4f46:b0:3dc:557f:6124 with SMTP id m6-20020a05600c4f4600b003dc557f6124mr5276318wmq.5.1675331587892; Thu, 02 Feb 2023 01:53:07 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id i13-20020a1c540d000000b003db03725e86sm4356234wmb.8.2023.02.02.01.53.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 01:53:07 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , Elijah Newren , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v6 11/19] commit-graph: fix a parse_options_concat() leak Date: Thu, 2 Feb 2023 10:52:42 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1392.g63e6d408230 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When the parse_options_concat() was added to this file in 84e4484f128 (commit-graph: use parse_options_concat(), 2021-08-23) we wouldn't free() it if we returned early in these cases. Since "result" is 0 by default we can "goto cleanup" in both cases, and only need to set "result" if write_commit_graph_reachable() fails. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/commit-graph.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c index 0102ac8540e..93704f95a9d 100644 --- a/builtin/commit-graph.c +++ b/builtin/commit-graph.c @@ -269,8 +269,8 @@ static int graph_write(int argc, const char **argv, const char *prefix) if (opts.reachable) { if (write_commit_graph_reachable(odb, flags, &write_opts)) - return 1; - return 0; + result = 1; + goto cleanup; } if (opts.stdin_packs) { From patchwork Thu Feb 2 09:52:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13125683 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 534B7C05027 for ; Thu, 2 Feb 2023 09:53:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232334AbjBBJx4 (ORCPT ); Thu, 2 Feb 2023 04:53:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232340AbjBBJx2 (ORCPT ); Thu, 2 Feb 2023 04:53:28 -0500 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9E4C22DEE for ; Thu, 2 Feb 2023 01:53:10 -0800 (PST) Received: by mail-wm1-x336.google.com with SMTP id j29-20020a05600c1c1d00b003dc52fed235so912215wms.1 for ; Thu, 02 Feb 2023 01:53:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vSfKwPOTPhummvWdXQiuGlyL7ZXHQm30fRx7ZuVDWTw=; b=KaU4oTIgmRZgSNyJbAIya5Vk//CJGPlDIvspf6kM2W8qB1Mw9fvavnRHp28YqzpTXY fe7BWGmX2ba0buZXwqieMSdMMPpvO/xmK8RkRrZ+DfeDwAW7XQ8FGOakV/nrDseEjH1l Md7RY4V9i8iLBbXJFiv8XKICAYMAyhvCVskamejv+jrvl844YBRroz2qsS0XPkDEyVT4 bEtsQFsuDqKWMt4f2DkMhKWvXCrtP6g5WhZxyO3JD6zrRqq//CpSYKFb2devPIOStI5H 0sCbeZtNNrHWEr+ZRjX5NFdj2WeoVhjxsygoeB2Yu/Vcrc2TBhKAFJGucfBJ+NiPxY1+ nw9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vSfKwPOTPhummvWdXQiuGlyL7ZXHQm30fRx7ZuVDWTw=; b=5nN/1EFPTuPEj0T27PXUZE+Q/j3p6G8o4IvbxXSfvzU+718KgM5dqwqKAC7czT3DVU tXJbxFoKYoGSgFO4sMqEO8uA3Pzm886cAu9C8PkVT5Vni9zFB4QFpA4wyS4ruShugXOj oEcwXfgRmZiITs2UPq9lF7kpbiiV2YO1MMOfuhqlqunAEUVB157hS1ybHgU0mqIoYRf/ 4Gu7VpKqpec0AaIne6UymoqHQoxOFH0BWVd62fcsxBdmue4pXNHg2F46jHb0O4ymVF1B 9+y5AVJuLBjRYnvk1QsJNugjYibYjRvhOx5oUPqYzha8JusrKxE3ThX/u1dZHKBLpTSk vPfQ== X-Gm-Message-State: AO0yUKVh6n+iWrr4os8ZwR2bsl0LMKyJtNmdkrgEiRx2j1zrQ4tTyhTL 0eOv6FQnvDAPMYKNK8Wje3zgN9KakbiYUxa0 X-Google-Smtp-Source: AK7set/mUtEVBIKOikbNkah1eY0tSwArvkat/B26lxmWI0YP9qDBxaILqWvvfYknP0gQuxGcHXjPEg== X-Received: by 2002:a05:600c:35c6:b0:3df:9858:c034 with SMTP id r6-20020a05600c35c600b003df9858c034mr1419484wmq.9.1675331588904; Thu, 02 Feb 2023 01:53:08 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id i13-20020a1c540d000000b003db03725e86sm4356234wmb.8.2023.02.02.01.53.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 01:53:08 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , Elijah Newren , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v6 12/19] show-branch: free() allocated "head" before return Date: Thu, 2 Feb 2023 10:52:43 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1392.g63e6d408230 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Stop leaking the "head" variable, which we've been leaking since it was originally added in [1], and in its current form since [2] 1. ed378ec7e85 (Make ref resolution saner, 2006-09-11) 2. d9e557a320b (show-branch: store resolved head in heap buffer, 2017-02-14). Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/show-branch.c | 1 + 1 file changed, 1 insertion(+) diff --git a/builtin/show-branch.c b/builtin/show-branch.c index c013abaf942..358ac3e519a 100644 --- a/builtin/show-branch.c +++ b/builtin/show-branch.c @@ -956,5 +956,6 @@ int cmd_show_branch(int ac, const char **av, const char *prefix) if (shown_merge_point && --extra < 0) break; } + free(head); return 0; } From patchwork Thu Feb 2 09:52:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13125684 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35801C61DA4 for ; Thu, 2 Feb 2023 09:53:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232512AbjBBJx5 (ORCPT ); Thu, 2 Feb 2023 04:53:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232355AbjBBJx2 (ORCPT ); Thu, 2 Feb 2023 04:53:28 -0500 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDCAE8A6F for ; Thu, 2 Feb 2023 01:53:10 -0800 (PST) Received: by mail-wm1-x333.google.com with SMTP id bg13-20020a05600c3c8d00b003d9712b29d2so3284131wmb.2 for ; Thu, 02 Feb 2023 01:53:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mCBJZiYhxnFipdNMubM2tB1sHl8TfZPdL6BTmJzIwPg=; b=pR0HLwrB9jBU0Yt0hUCnzbj2Hjkw/E++4hhHxRastbGU4Y131DZHiye9rUrL/KqsOW FwY51L4rLC/sFBzeENlom8s0YNVAc/qghX2KQah9cc7T6qWsMtnRy3GtTUZYo0m0KvmV YmKAg52fIzMtOfak2xvUypfJl80qjqPjfj62EHMkawIdfMit/ztvxs0rD505XvoX4D+h WN8j5xnDjqiL2UPIplJUIh+3r7DVUg4aOUQKhrrKd8yQC8BNXJ+qjbIcHoyDDQkJ70xh jxEnLinI+EXtaI0cOrtsR8bdOEjXmV//29jxtOUlEMSuvg2tMgJi7URhoSAwg7RPBV9f njnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mCBJZiYhxnFipdNMubM2tB1sHl8TfZPdL6BTmJzIwPg=; b=W+TjjphAwi18X8qpmjKuiwM7if4T7sYp1p5zGDGtXFJd/wFaUrBxT/g0rR/ZwFz8Zz tetN267Eq9hGg7zq74vTD6F+7bXwIlEFSChTHco3B9lyLUGXrKPYarIPXqgfuo2tCC84 VveCXF7qdL8sywgO7se0qEVSD/Uw8xzAXSaaX7PQMtTPFkIJk6rtPwa1z7KT25pe1Pwu v5AyAjcmx83cBiTufJ6wRg8Gs2cacPHRwGn49tNui1KyPAEj7A636KFNR9E+DOAb+20T sh2gvQTDJmcQ9gpXWI06CuBWXiQYkFzVNnoeOse31b+4egSx2p+ack6TxHoldUhxDqDP yqsQ== X-Gm-Message-State: AO0yUKUb0QvBzEmKs4p6TlXiFh3/t1ny6RGSdsq800TwhhO63jDS7V1j 36quhM8fZDiCJVAwWXf0SVm+ZShOflpHkepd X-Google-Smtp-Source: AK7set/TBMSqRX9JrgAFHAHVgldjOs1gfCUjnbQeHkHG4W9Ahdbcz+wW1IrN4ZtGehzDhLyFhb9kJA== X-Received: by 2002:a05:600c:3556:b0:3db:331b:bd57 with SMTP id i22-20020a05600c355600b003db331bbd57mr5417035wmq.23.1675331589898; Thu, 02 Feb 2023 01:53:09 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id i13-20020a1c540d000000b003db03725e86sm4356234wmb.8.2023.02.02.01.53.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 01:53:09 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , Elijah Newren , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v6 13/19] builtin/merge.c: use fixed strings, not "strbuf", fix leak Date: Thu, 2 Feb 2023 10:52:44 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1392.g63e6d408230 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Follow-up 465028e0e25 (merge: add missing strbuf_release(), 2021-10-07) and address the "msg" memory leak in this block. We could free "&msg" before the "goto done" here, but even better is to avoid allocating it in the first place. By repeating the "Fast-forward" string here we can avoid using a "struct strbuf" altogether. Suggested-by: René Scharfe Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/merge.c | 11 ++++------- t/t6439-merge-co-error-msgs.sh | 1 + 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/builtin/merge.c b/builtin/merge.c index 74de2ebd2b3..32733e551d4 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -1560,7 +1560,9 @@ int cmd_merge(int argc, const char **argv, const char *prefix) !common->next && oideq(&common->item->object.oid, &head_commit->object.oid)) { /* Again the most common case of merging one remote. */ - struct strbuf msg = STRBUF_INIT; + const char *msg = have_message ? + "Fast-forward (no commit created; -m option ignored)" : + "Fast-forward"; struct commit *commit; if (verbosity >= 0) { @@ -1570,10 +1572,6 @@ int cmd_merge(int argc, const char **argv, const char *prefix) find_unique_abbrev(&remoteheads->item->object.oid, DEFAULT_ABBREV)); } - strbuf_addstr(&msg, "Fast-forward"); - if (have_message) - strbuf_addstr(&msg, - " (no commit created; -m option ignored)"); commit = remoteheads->item; if (!commit) { ret = 1; @@ -1592,9 +1590,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix) goto done; } - finish(head_commit, remoteheads, &commit->object.oid, msg.buf); + finish(head_commit, remoteheads, &commit->object.oid, msg); remove_merge_branch_state(the_repository); - strbuf_release(&msg); goto done; } else if (!remoteheads->next && common->next) ; diff --git a/t/t6439-merge-co-error-msgs.sh b/t/t6439-merge-co-error-msgs.sh index 52cf0c87690..0cbec57cdab 100755 --- a/t/t6439-merge-co-error-msgs.sh +++ b/t/t6439-merge-co-error-msgs.sh @@ -5,6 +5,7 @@ test_description='unpack-trees error messages' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh From patchwork Thu Feb 2 09:52:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13125686 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3B3BC61DA4 for ; Thu, 2 Feb 2023 09:54:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232662AbjBBJyH (ORCPT ); Thu, 2 Feb 2023 04:54:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232103AbjBBJxs (ORCPT ); Thu, 2 Feb 2023 04:53:48 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D336A2278A for ; Thu, 2 Feb 2023 01:53:12 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id k16so928529wms.2 for ; Thu, 02 Feb 2023 01:53:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0P0Tf781grCDb8NI2R0AXLKHHdPl9xW3rDX14iewyyU=; b=G8ODDhKiLTBASKg7g3WPC+KVTgyNf5wwlnNFpVYdQJQ+0aGNlTp09L1SYl8xtC6u+b J9sI1PZ4lkdPMIuR5zMjlip37kdvRS0Y+qptXmYXAfny1JfE03lMZl68RDbW5OvUXzFx YP2uE5CFYaQuGPRG4XxBWK+Oyx1Ww0sU7W5bZ4eCWhyMTCXxLQR8j4yy5eahgAP5wnE9 pvLGcu0mOHpKl+JkAEX80o44gK4X+Lw2dj/a5vDrfAxalFdmvWmqwxzb0RhPukCbgI9c CdCxe0cxEmoSSNNq228fZeeQlTFWRgXFXhONeuJ3K+Xo4INLwWFwC6sRtRXd+fa0viIA 5X+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0P0Tf781grCDb8NI2R0AXLKHHdPl9xW3rDX14iewyyU=; b=hqNuVeNTTNLznLqobp7+WSPQdgJMaNrrUQvH5Vj3ml8s5l1sE+2UK+n5wlomQ0nh1G BlnvqpzKesu/Z8qCVKT4xmxCk2Kwu0juqyxGguqG6PkxHnZ9li9I1YGZkQtd+iwOfs3b tf6eLAEA9fO3qRfPbTNl1fDl8fI53iEOc7IyjgDMWYsoMAg2ZPYa058maLlKGXzVSPDs OkVmORDvw9KfRUr1HzRJ+kGVPv76GUqXQQaXc+9jqRivt6grqyomxsID+Of25CGS3j8r 3dJNuR35dJAIDdYP4ILOS0RXiyv7myRyWglTgCISQnHooK94ciogR/CzkrO36oJkBxf8 oZRA== X-Gm-Message-State: AO0yUKW3NgCQET1KrRNMnX/BZGNK82GuM+i7tJ9wtHBjS/r4HtUr+Ldj j3lrF8Ona1hWNlU2neFXIoDqL7keVcuYSMUp X-Google-Smtp-Source: AK7set/iZbh6InJSYeyKjq0JyjWQPkHt/yTV/LtJnP45yV2ts4AYPihFQsLFVUpehiMDkCRisU8GJg== X-Received: by 2002:a05:600c:1e24:b0:3da:f665:5b66 with SMTP id ay36-20020a05600c1e2400b003daf6655b66mr5888621wmb.6.1675331590950; Thu, 02 Feb 2023 01:53:10 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id i13-20020a1c540d000000b003db03725e86sm4356234wmb.8.2023.02.02.01.53.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 01:53:10 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , Elijah Newren , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v6 14/19] builtin/merge.c: free "&buf" on "Your local changes..." error Date: Thu, 2 Feb 2023 10:52:45 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1392.g63e6d408230 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Plug a memory leak introduced in [1], since that change didn't follow the "goto done" pattern introduced in [2] we'd leak the "&buf" memory. 1. e4cdfe84a0d (merge: abort if index does not match HEAD for trivial merges, 2022-07-23) 2. d5a35c114ab (Copy resolve_ref() return value for longer use, 2011-11-13) Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/merge.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/builtin/merge.c b/builtin/merge.c index 32733e551d4..5a834b1f291 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -1618,7 +1618,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix) error(_("Your local changes to the following files would be overwritten by merge:\n %s"), sb.buf); strbuf_release(&sb); - return 2; + ret = 2; + goto done; } /* See if it is really trivial. */ From patchwork Thu Feb 2 09:52:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13125687 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99F7AC05027 for ; Thu, 2 Feb 2023 09:54:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232548AbjBBJyJ (ORCPT ); Thu, 2 Feb 2023 04:54:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232161AbjBBJxt (ORCPT ); Thu, 2 Feb 2023 04:53:49 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 207F72BF1C for ; Thu, 2 Feb 2023 01:53:13 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id q10-20020a1cf30a000000b003db0edfdb74so3766792wmq.1 for ; Thu, 02 Feb 2023 01:53:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dmmHrGWZmIzw3znsYKxDzhLVGs5tHLKflSJSBmxcG6A=; b=HHGSmpbCL4dWLYmCv828m6B96XJf/ZHza0Jd+SP5f7rhtWrLMYpY+tH7ke6IS60+KT oaihdew+EX9ZW8TzwfcP3Lu1FuCEbX/0bs0MCFHPDrHX6P++3Hr6+gVB0f/sg9X95iqT PlaTXdlZ99R/kVBLu8weY/Hr4K+ZhS3aJcBRh52Ct7JXgZ/5JJlad+fjthJFp7hhctNZ gTSclCzx71olIFe99VROFZpRr+ifweKY/4MLkKIsuIutS29nDYepqXPEcQ8G58SGsuDD V+sOvMnUkIpA0MM6gqE4SbTGye9IPjfb2Jx6b98ghMjkOfSrRdAYUCoGQdtCuOn8gcBx xfKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dmmHrGWZmIzw3znsYKxDzhLVGs5tHLKflSJSBmxcG6A=; b=TC6SyH4U8Nu8Zhf4em8UejnXeYo3fpwgs0LMqlrBARvwa613RFkNpaQdooIvwcAUlR VBXsB0nbrPf+lGWwyuCTaA0zCJnnAaLc2UPcrGnGQAKhO0TrCCWF7Hsu2afbqMxIQ705 cCjgxdsjSx6xXDmeiG0bY68ijhKwjRGzFmSTEODg0j2crujFWI7T6OVk3XajalXSzy8u gNiAPyi90nrwvgRd/qESbTDvZcsyk05qn9f/ZCLdrewbM4+I6aJFBqexvylSXFCp0Cbc iCTcKFMbFrYeQP39B/+C3Ih2+xepbrpcBAb/66Nigs/O2oEol0QpU1AnGHx2agx/0ghQ 4mRQ== X-Gm-Message-State: AO0yUKVVUrT0s3jkpEQoN0IVrdfiZRDLK2VVA7sua5DUEmpDMjhPfvXu JRE1h6Mc6OOwaiWGnzhIaWkfSgmHkEseNN6J X-Google-Smtp-Source: AK7set//Jg8iCKvjZJOrvKBzGMtDnhftmr7StGQpaX2xxoN+tMf1JzeOdrVfk5w2Zq4f35m4+8So6w== X-Received: by 2002:a05:600c:548d:b0:3db:114:a67f with SMTP id iv13-20020a05600c548d00b003db0114a67fmr5205514wmb.17.1675331591973; Thu, 02 Feb 2023 01:53:11 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id i13-20020a1c540d000000b003db03725e86sm4356234wmb.8.2023.02.02.01.53.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 01:53:11 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , Elijah Newren , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v6 15/19] grep.c: refactor free_grep_patterns() Date: Thu, 2 Feb 2023 10:52:46 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1392.g63e6d408230 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Refactor the free_grep_patterns() function to split out the freeing of the "struct grep_pat" it contains. Right now we're only freeing the "pattern_list", but we should be freeing another member of the same type, which we'll do in the subsequent commit. Let's also replace the "return" if we don't have an "opt->pattern_expression" with a conditional call of free_pattern_expr(). Before db84376f981 (grep.c: remove "extended" in favor of "pattern_expression", fix segfault, 2022-10-11) the pattern here was: if (!x) return; free_pattern_expr(y); While at it, instead of: if (!x) return; free_pattern_expr(x); Let's instead do: if (x) free_pattern_expr(x); This will make it easier to free additional members from free_grep_patterns() in the future. Helped-by: Elijah Newren Signed-off-by: Ævar Arnfjörð Bjarmason --- grep.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/grep.c b/grep.c index 1687f65b64f..f8708e1fd20 100644 --- a/grep.c +++ b/grep.c @@ -769,11 +769,11 @@ static void free_pattern_expr(struct grep_expr *x) free(x); } -void free_grep_patterns(struct grep_opt *opt) +static void free_grep_pat(struct grep_pat *pattern) { struct grep_pat *p, *n; - for (p = opt->pattern_list; p; p = n) { + for (p = pattern; p; p = n) { n = p->next; switch (p->token) { case GREP_PATTERN: /* atom */ @@ -790,10 +790,14 @@ void free_grep_patterns(struct grep_opt *opt) } free(p); } +} - if (!opt->pattern_expression) - return; - free_pattern_expr(opt->pattern_expression); +void free_grep_patterns(struct grep_opt *opt) +{ + free_grep_pat(opt->pattern_list); + + if (opt->pattern_expression) + free_pattern_expr(opt->pattern_expression); } static const char *end_of_line(const char *cp, unsigned long *left) From patchwork Thu Feb 2 09:52:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13125688 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 377C6C61DA4 for ; Thu, 2 Feb 2023 09:54:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232594AbjBBJyK (ORCPT ); Thu, 2 Feb 2023 04:54:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232467AbjBBJxs (ORCPT ); Thu, 2 Feb 2023 04:53:48 -0500 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2112D2CFCA for ; Thu, 2 Feb 2023 01:53:14 -0800 (PST) Received: by mail-wm1-x32c.google.com with SMTP id j32-20020a05600c1c2000b003dc4fd6e61dso3273046wms.5 for ; Thu, 02 Feb 2023 01:53:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tKBip05bFRjkGOC9756wRM6dGN3CFpVpqtHGf/xgzkw=; b=D6goKpIMPToDCeZfp3BvFRwj+YzLlythei1VswoNNaSQqgyAWrNyUR1VoEvUzFBefm zfJIKFKnnIp8Xn80RG60gHAG/0j27QK4yvF+puaEygQ8atAiozXMy0cjGtAem3d0hwNv EeJPwNYANu+ri+yzPOmVLINUjMwYyvvlGlEliNxxLKtUXHocDx7yCqbYLSy+5CmOMdtJ BtULFCVuh1P2Wnqm116cNaI7SsCjLEfHH+FnEwBT3dnCLATRfYrNCbkEmj5RnL3bXJ12 PAaK3X4MPCfBRftPeJJhugcKen7n0WFjQZ8+nTqghs5tO7JKakoiJlnScpbNidjAhnJt xn2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tKBip05bFRjkGOC9756wRM6dGN3CFpVpqtHGf/xgzkw=; b=IwWDxo6+hgvxps/4CCHzhoJSE8piC+y1PlCBkxpoErYfQZU3KL3Jevrpn0kGTvoUTi 4aD1TwPzeytHFcND7cO9mniazDC+VypWIgmqD1Tmi542Y0hoRrH5rxVkRyEicJ1F3dUn w9VasOgnJBuDymd61+WZyWZpb1erEPD6y3tVGJeqJLxeacIDJdSyaL7HjmtdPZmXUe27 dcng2eKjcsgw+adJ/Z2EEsHZJ8tAFzvVgo4HXXb2V8AMDFN+uO2KzrHqpedcL4HqpAh8 WwHIbBIYTmPstGQHD9rPNt2fgLRieRjjUWwlA5i0yfx0J7tFVLGrxAsIBiySpZUYMPtr 2NoQ== X-Gm-Message-State: AO0yUKWMso7z+21eExabQa4Z5shsuV2IjLV6OeBdclh0iP8T0eqcfjyh 83e++pdHPtTz8Lp2zFRFpSihdEYvzwLR2XPx X-Google-Smtp-Source: AK7set+PI27QOuEofv10D1tNMyIaV/MZYLqPm8YFgFE4e1Zhr/8GJYZPRTnlU2apxu8jQEUxQl057Q== X-Received: by 2002:a05:600c:4f07:b0:3dc:5ad1:583d with SMTP id l7-20020a05600c4f0700b003dc5ad1583dmr5402984wmq.18.1675331593049; Thu, 02 Feb 2023 01:53:13 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id i13-20020a1c540d000000b003db03725e86sm4356234wmb.8.2023.02.02.01.53.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 01:53:12 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , Elijah Newren , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v6 16/19] grep API: plug memory leaks by freeing "header_list" Date: Thu, 2 Feb 2023 10:52:47 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1392.g63e6d408230 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When the "header_list" struct member was added in [1], freeing this field was neglected. Fix that now, so that commands like ./git -P log -1 --color=always --author=A origin/master will run leak-free. 1. 80235ba79ef ("log --author=me --grep=it" should find intersection, not union, 2010-01-17) Helped-by: Elijah Newren Signed-off-by: Ævar Arnfjörð Bjarmason --- grep.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grep.c b/grep.c index f8708e1fd20..92ece4b7fa3 100644 --- a/grep.c +++ b/grep.c @@ -795,6 +795,7 @@ static void free_grep_pat(struct grep_pat *pattern) void free_grep_patterns(struct grep_opt *opt) { free_grep_pat(opt->pattern_list); + free_grep_pat(opt->header_list); if (opt->pattern_expression) free_pattern_expr(opt->pattern_expression); From patchwork Thu Feb 2 09:52:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13125690 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03F3DC61DA4 for ; Thu, 2 Feb 2023 09:54:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232481AbjBBJyO (ORCPT ); Thu, 2 Feb 2023 04:54:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231715AbjBBJxt (ORCPT ); Thu, 2 Feb 2023 04:53:49 -0500 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 211D42CFF5 for ; Thu, 2 Feb 2023 01:53:16 -0800 (PST) Received: by mail-wm1-x332.google.com with SMTP id m16-20020a05600c3b1000b003dc4050c94aso894339wms.4 for ; Thu, 02 Feb 2023 01:53:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MCUVq8Ly+j2m0SakiS1nf66ZRSF/UKj6a5BQSnVZHZE=; b=k3noSsu4yOsq/SdpgayDZNECR24CDx1+bFNvELhIX4wU+VySOJqgVqNwbxCYA3/Byr n74MDmHq2pWnm+EbjwA7QU9mvU1QUq/4XDvU0f5S0fGwUaMp8lelqdiY2bk6hPnR8EdB bi55WXyXMjCdwnojIALB9tFiZkKbLT9efOTxt0uRlSmiXwFSjipYjOx8nQDFEtsNr7i0 WHi3vHaOm1Tjd32qHXjIDl0B4YQK6IkkW+l6fP0O4vOfudhvC6fBND0qPFjwO0DAidQX pJnApIl7CPCdUM2zhvWzhb+Cd7gejinFmi27BfA5BHrj3OESn/UNqLWAPF7G35R8mNBn 2l7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MCUVq8Ly+j2m0SakiS1nf66ZRSF/UKj6a5BQSnVZHZE=; b=NGPRdfy60nS0+ywVs31FmLw3L4QVu7MBnVZ933jmEfp6cv3cV0FmeENGSKgTthYBGj jABkz5vKZe81xX3tPQfsQ/IQdh791/CiprTmCV6LT3B4DzCU5mMbE04KY4Ww7ieJUut/ dEiD4+sgOraBHqv/lK9Gvb6tDJT3B34Z4RZYPDTFE+8wdvaV57DQqPhF4d2B7FYe7Ymt hRuaRnN7yfYqv7L4kdSQATseXaYIK0xSJICtpZq+d8mSc4plv0Td7gLonfSk2WC8Q3/a piRxaclDJbmTFA2Zl7RbefQzB1CgQR+dFWlIXKQ7QAO0d3L/uvLQY6zhxDr+ya65rGhL B9PQ== X-Gm-Message-State: AO0yUKXwtOIW9HjQJHq5YV1u1WmBslMJ7W04uL8tBBp3ls1bmePHmKJS tbTI8Ee5bdC7uyG2uHISBLfLo+7YkP/A6M9Z X-Google-Smtp-Source: AK7set+tYHvYhxzTx5sGFimSA4iAdM9BLrFiapea12svhbJVtWY+gjAFEBb568G2xuK4VOVlbaXsNA== X-Received: by 2002:a05:600c:600c:b0:3db:1afd:ac36 with SMTP id az12-20020a05600c600c00b003db1afdac36mr5665178wmb.32.1675331594189; Thu, 02 Feb 2023 01:53:14 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id i13-20020a1c540d000000b003db03725e86sm4356234wmb.8.2023.02.02.01.53.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 01:53:13 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , Elijah Newren , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v6 17/19] receive-pack: free() the "ref_name" in "struct command" Date: Thu, 2 Feb 2023 10:52:48 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1392.g63e6d408230 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Fix a memory leak that's been with us since this code was introduced in 575f497456e (Add first cut at "git-receive-pack", 2005-06-29). See eb1af2df0b1 (git-receive-pack: start parsing ref update commands, 2005-06-29) for the later change that refactored the code to add the "ref_name" member. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/receive-pack.c | 10 ++++++++++ t/t5405-send-pack-rewind.sh | 1 + t/t5406-remote-rejects.sh | 1 + t/t5507-remote-environment.sh | 2 ++ t/t5522-pull-symlink.sh | 1 + t/t5527-fetch-odd-refs.sh | 1 + t/t5560-http-backend-noserver.sh | 1 + t/t5561-http-backend.sh | 1 + t/t5562-http-backend-content-length.sh | 2 ++ t/t5705-session-id-in-capabilities.sh | 1 + 10 files changed, 21 insertions(+) diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index a90af303630..451bad776c6 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -2032,6 +2032,15 @@ static struct command **queue_command(struct command **tail, return &cmd->next; } +static void free_commands(struct command *commands) +{ + while (commands) { + struct command *next = commands->next; + free(commands); + commands = next; + } +} + static void queue_commands_from_cert(struct command **tail, struct strbuf *push_cert) { @@ -2569,6 +2578,7 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix) run_receive_hook(commands, "post-receive", 1, &push_options); run_update_post_hook(commands); + free_commands(commands); string_list_clear(&push_options, 0); if (auto_gc) { struct child_process proc = CHILD_PROCESS_INIT; diff --git a/t/t5405-send-pack-rewind.sh b/t/t5405-send-pack-rewind.sh index 11f03239a06..1686ac13aa6 100755 --- a/t/t5405-send-pack-rewind.sh +++ b/t/t5405-send-pack-rewind.sh @@ -5,6 +5,7 @@ test_description='forced push to replace commit we do not have' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success setup ' diff --git a/t/t5406-remote-rejects.sh b/t/t5406-remote-rejects.sh index dcbeb420827..d6a99466338 100755 --- a/t/t5406-remote-rejects.sh +++ b/t/t5406-remote-rejects.sh @@ -2,6 +2,7 @@ test_description='remote push rejects are reported by client' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'setup' ' diff --git a/t/t5507-remote-environment.sh b/t/t5507-remote-environment.sh index e6149295b18..c6a6957c500 100755 --- a/t/t5507-remote-environment.sh +++ b/t/t5507-remote-environment.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='check environment showed to remote side of transports' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'set up "remote" push situation' ' diff --git a/t/t5522-pull-symlink.sh b/t/t5522-pull-symlink.sh index bcff460d0a2..394bc60cb8e 100755 --- a/t/t5522-pull-symlink.sh +++ b/t/t5522-pull-symlink.sh @@ -2,6 +2,7 @@ test_description='pulling from symlinked subdir' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh # The scenario we are building: diff --git a/t/t5527-fetch-odd-refs.sh b/t/t5527-fetch-odd-refs.sh index e2770e4541f..98ece27c6a0 100755 --- a/t/t5527-fetch-odd-refs.sh +++ b/t/t5527-fetch-odd-refs.sh @@ -4,6 +4,7 @@ test_description='test fetching of oddly-named refs' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh # afterwards we will have: diff --git a/t/t5560-http-backend-noserver.sh b/t/t5560-http-backend-noserver.sh index d30cf4f5b83..f75068de648 100755 --- a/t/t5560-http-backend-noserver.sh +++ b/t/t5560-http-backend-noserver.sh @@ -4,6 +4,7 @@ test_description='test git-http-backend-noserver' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh HTTPD_DOCUMENT_ROOT_PATH="$TRASH_DIRECTORY" diff --git a/t/t5561-http-backend.sh b/t/t5561-http-backend.sh index 9c57d843152..e1d3b8caed0 100755 --- a/t/t5561-http-backend.sh +++ b/t/t5561-http-backend.sh @@ -4,6 +4,7 @@ test_description='test git-http-backend' 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-httpd.sh diff --git a/t/t5562-http-backend-content-length.sh b/t/t5562-http-backend-content-length.sh index b68ec22d3fd..7ee9858a78b 100755 --- a/t/t5562-http-backend-content-length.sh +++ b/t/t5562-http-backend-content-length.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='test git-http-backend respects CONTENT_LENGTH' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_lazy_prereq GZIP 'gzip --version' diff --git a/t/t5705-session-id-in-capabilities.sh b/t/t5705-session-id-in-capabilities.sh index ed38c76c290..b8a722ec27e 100755 --- a/t/t5705-session-id-in-capabilities.sh +++ b/t/t5705-session-id-in-capabilities.sh @@ -2,6 +2,7 @@ test_description='session ID in capabilities' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh REPO="$(pwd)/repo" From patchwork Thu Feb 2 09:52:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13125689 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0DB5FC05027 for ; Thu, 2 Feb 2023 09:54:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232602AbjBBJyM (ORCPT ); Thu, 2 Feb 2023 04:54:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232481AbjBBJxt (ORCPT ); Thu, 2 Feb 2023 04:53:49 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C66A2E815 for ; Thu, 2 Feb 2023 01:53:17 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id l8so921807wms.3 for ; Thu, 02 Feb 2023 01:53:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zSeG8G5IBWUhE7M7m2tnVGyhtyadLy69PJCQ+du+Y8E=; b=fvqmnqhB98CeslHf11s4yEQyjHDsHxgWER0+sMWDZWs4B33n26GnjuibtXka7R5f1a YNTb1y3fMXdg8hb9ADW8hI8L/6NzTRBnFPlVhQK+jcSHb4s3QsAht7j2oH3R5pN50jKk J923/2E+CpweXz5eWgPBtwpaSacqQCNMJGPaSSTiRFNXMs41a2q47tAa39pq1FGOrIUH ER/HwUJfbIZeJwyRgbxrSQtHZWy3IfGnou5YH08cnlmgD6yZ+b57bILRrg7fvFT8/pkG mn6LxBQDIDSnqPIZmvNWMLym1mT9AkIbr60ZlmPgnO7RvGV3oj2lCw26pChywV1Fr7lx roYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zSeG8G5IBWUhE7M7m2tnVGyhtyadLy69PJCQ+du+Y8E=; b=6Q93960S4G06ePaGhThWaRleiHUUhy5nFJ4j5xL9lhfCAVYE0bAbONcEJc/SvE0mMH QV0gexeGybnDqwkVJBNMbDujRiEAumHjc/IqnhgmGTrdpC7dJGmDA1gm3IrlZf74SCDT WqLwflFlrXGf6/k06Smc51Au4qwas+HAyqNt+DT6m+methY480rICyvE4CEuaijMIli+ i6K78H4J/NeJO5FIAjxI49ESVHVNdJwo0U3oVe48nFHRzjbT02/u8Ser7t4imEBHGFWO 8zoIgIgjQx6SlxIEhA6XZbvxHBukB+LA+yiqLuq2LsSC2GVL+BVjLPyqgwLsZ40gd4Q7 vHNg== X-Gm-Message-State: AO0yUKU+S6Jfc97rqa1ZE/VegKZawiEvCcwV1ZOazNwcgK23Yr5nIcit N0yQcrIyklXIf6bgUxDJMZSMtkOibLKoN0rh X-Google-Smtp-Source: AK7set+CixBIlSMo34J+3mt7r0OxdfqBWeBMa73eIsDayoIP/ccUuRCD8230hgu4QIiMw0a4a/1lNQ== X-Received: by 2002:a05:600c:3b0f:b0:3de:1d31:1048 with SMTP id m15-20020a05600c3b0f00b003de1d311048mr4895659wms.29.1675331595199; Thu, 02 Feb 2023 01:53:15 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id i13-20020a1c540d000000b003db03725e86sm4356234wmb.8.2023.02.02.01.53.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 01:53:14 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , Elijah Newren , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v6 18/19] push: refactor refspec_append_mapped() for subsequent leak-fix Date: Thu, 2 Feb 2023 10:52:49 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1392.g63e6d408230 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The set_refspecs() caller of refspec_append_mapped() (added in [1]) left open the question[2] of whether the "remote" we lazily fetch might be NULL in the "[...]uniquely name our ref?" case, as remote_get() can return NULL. If we got past the "[...]uniquely name our ref?" case we'd have already segfaulted if we tried to dereference it as "remote->push.nr". In these cases the config mechanism & previous remote validation will have bailed out earlier. Let's refactor this code to clarify that, we'll now BUG() out if we can't get a "remote", and will no longer retrieve it for these common cases where we don't need it. 1. ca02465b413 (push: use remote.$name.push as a refmap, 2013-12-03) 2. https://lore.kernel.org/git/c0c07b89-7eaf-21cd-748e-e14ea57f09fd@web.de/ Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/push.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/builtin/push.c b/builtin/push.c index 60ac8017e52..97b35eca3ab 100644 --- a/builtin/push.c +++ b/builtin/push.c @@ -63,16 +63,9 @@ static struct refspec rs = REFSPEC_INIT_PUSH; static struct string_list push_options_config = STRING_LIST_INIT_DUP; static void refspec_append_mapped(struct refspec *refspec, const char *ref, - struct remote *remote, struct ref *local_refs) + struct remote *remote, struct ref *matched) { const char *branch_name; - struct ref *matched = NULL; - - /* Does "ref" uniquely name our ref? */ - if (count_refspec_match(ref, local_refs, &matched) != 1) { - refspec_append(refspec, ref); - return; - } if (remote->push.nr) { struct refspec_item query; @@ -120,12 +113,24 @@ static void set_refspecs(const char **refs, int nr, const char *repo) die(_("--delete only accepts plain target ref names")); refspec_appendf(&rs, ":%s", ref); } else if (!strchr(ref, ':')) { - if (!remote) { - /* lazily grab remote and local_refs */ - remote = remote_get(repo); + struct ref *matched = NULL; + + /* lazily grab local_refs */ + if (!local_refs) local_refs = get_local_heads(); + + /* Does "ref" uniquely name our ref? */ + if (count_refspec_match(ref, local_refs, &matched) != 1) { + refspec_append(&rs, ref); + } else { + /* lazily grab remote */ + if (!remote) + remote = remote_get(repo); + if (!remote) + BUG("must get a remote for repo '%s'", repo); + + refspec_append_mapped(&rs, ref, remote, matched); } - refspec_append_mapped(&rs, ref, remote, local_refs); } else refspec_append(&rs, ref); } From patchwork Thu Feb 2 09:52:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13125691 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4FD25C05027 for ; Thu, 2 Feb 2023 09:54:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232552AbjBBJyQ (ORCPT ); Thu, 2 Feb 2023 04:54:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232598AbjBBJxt (ORCPT ); Thu, 2 Feb 2023 04:53:49 -0500 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 219633401B for ; Thu, 2 Feb 2023 01:53:18 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id o18so1157487wrj.3 for ; Thu, 02 Feb 2023 01:53:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8jEc1apoOfoCEKcr38kLtFCQVvqJUioy2AOjyZ5C0m8=; b=pnhG8XF9Lm+mY3VtDChhRpqHcSXEiWDencG/qRP08/XB64d1aAfwLLPM4IPMSl0+h6 HlaxCJc6zU8lNKv1gZRMg72hzSawhz+zDGTgedl3IOHmBArWHtFq6u+aFJ3WbbB2GUIU gTHYizAswZ6H6GsS8msCIptSHCxMp/8ZqzbYzvFcfcgG8ajbkXvlDo0q2Mii8R9/WbyL HdLFca2THqrtCr+8Fgq0p6F3SL71WkmndIWrdl4W9FBg0Cg6LZGxgfnMQx01flqj0Dnp Ewh5X3k1QyfvM7JE16F33Oi2hH9NGnGhUoVTvCqqCKI/rjl9ntORpCSGajU32R2dONpl QfuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8jEc1apoOfoCEKcr38kLtFCQVvqJUioy2AOjyZ5C0m8=; b=YP3+cDqIca+pG5ylUsT9E4+aEf514VTH9Nr18wz/JXuoqAas7N03p1IVlilLfSapQ7 wNySMkdCAmCAqDJKPE9FCFfh0OMrGw6X5dgQblU4iDxjhbafDErBqKt9iKu3X55K8Gzl yIrqChTr3JyGezY0Cy6YAhSGCzJJDfDw8HJPDuCa+dqbBzU7PJc84c2OIXZrVn6XMSrR 7nvDE8CNhqK/4RQuHw8f+3YttddY06rdw04NJvvT6Gtshn/X0mAokjggH2tfNI3bKFOG EFI8JOKWo4983N4RNT0td7I9pwO5tcCdYosB/oZw1bo5gaI7fV5XdsHlWr1Z9cZFRIxe gZQg== X-Gm-Message-State: AO0yUKWULy8t2887tZZAUg7nc85nvQEV/wCPd22dqOI3UGAciVQ3R/T6 1lzb7N8XGra4ws6+O2XkanSnV3ELNdPF83QN X-Google-Smtp-Source: AK7set/1m46D61nYfxmCPlocmykUTTPeKqs0lm2CnL1vA5AOKQkelUMoPmQuxWkvf7ztw90DPCU5Uw== X-Received: by 2002:a5d:4d01:0:b0:2b6:7876:3cd4 with SMTP id z1-20020a5d4d01000000b002b678763cd4mr5257009wrt.16.1675331596241; Thu, 02 Feb 2023 01:53:16 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id i13-20020a1c540d000000b003db03725e86sm4356234wmb.8.2023.02.02.01.53.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 01:53:15 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: =?utf-8?q?Ren=C3=A9_Scharfe?= , Junio C Hamano , Eric Sunshine , Elijah Newren , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH v6 19/19] push: free_refs() the "local_refs" in set_refspecs() Date: Thu, 2 Feb 2023 10:52:50 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1392.g63e6d408230 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Fix a memory leak that's been with us since this code was added in ca02465b413 (push: use remote.$name.push as a refmap, 2013-12-03). The "remote = remote_get(...)" added in the same commit would seem to leak based only on the context here, but that function is a wrapper for sticking the remotes we fetch into "the_repository->remote_state". See fd3cb0501e1 (remote: move static variables into per-repository struct, 2021-11-17) for the addition of code in repository.c that free's the "remote" allocated here. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/push.c | 1 + t/t1416-ref-transaction-hooks.sh | 1 + t/t2402-worktree-list.sh | 1 + t/t5504-fetch-receive-strict.sh | 1 + t/t5523-push-upstream.sh | 1 + t/t5529-push-errors.sh | 2 ++ t/t5546-receive-limits.sh | 2 ++ t/t5547-push-quarantine.sh | 2 ++ t/t5606-clone-options.sh | 1 + t/t5810-proto-disable-local.sh | 2 ++ t/t5813-proto-disable-ssh.sh | 2 ++ t/t7409-submodule-detached-work-tree.sh | 1 + t/t7416-submodule-dash-url.sh | 2 ++ t/t7450-bad-git-dotfiles.sh | 2 ++ 14 files changed, 21 insertions(+) diff --git a/builtin/push.c b/builtin/push.c index 97b35eca3ab..8f7d326ab3f 100644 --- a/builtin/push.c +++ b/builtin/push.c @@ -134,6 +134,7 @@ static void set_refspecs(const char **refs, int nr, const char *repo) } else refspec_append(&rs, ref); } + free_refs(local_refs); } static int push_url_of_remote(struct remote *remote, const char ***url_p) diff --git a/t/t1416-ref-transaction-hooks.sh b/t/t1416-ref-transaction-hooks.sh index 27731722a5b..b32ca798f9f 100755 --- a/t/t1416-ref-transaction-hooks.sh +++ b/t/t1416-ref-transaction-hooks.sh @@ -5,6 +5,7 @@ test_description='reference transaction hooks' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success setup ' diff --git a/t/t2402-worktree-list.sh b/t/t2402-worktree-list.sh index 79e0fce2d90..9ad9be0c208 100755 --- a/t/t2402-worktree-list.sh +++ b/t/t2402-worktree-list.sh @@ -5,6 +5,7 @@ test_description='test git worktree list' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'setup' ' diff --git a/t/t5504-fetch-receive-strict.sh b/t/t5504-fetch-receive-strict.sh index 88d3c56750a..0b8ab4afdbe 100755 --- a/t/t5504-fetch-receive-strict.sh +++ b/t/t5504-fetch-receive-strict.sh @@ -4,6 +4,7 @@ test_description='fetch/receive strict mode' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'setup and inject "corrupt or missing" object' ' diff --git a/t/t5523-push-upstream.sh b/t/t5523-push-upstream.sh index fdb42920564..c9acc076353 100755 --- a/t/t5523-push-upstream.sh +++ b/t/t5523-push-upstream.sh @@ -4,6 +4,7 @@ test_description='push with --set-upstream' 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-terminal.sh diff --git a/t/t5529-push-errors.sh b/t/t5529-push-errors.sh index ce85fd30ad1..0247137cb36 100755 --- a/t/t5529-push-errors.sh +++ b/t/t5529-push-errors.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='detect some push errors early (before contacting remote)' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'setup commits' ' diff --git a/t/t5546-receive-limits.sh b/t/t5546-receive-limits.sh index 0b0e987fdb7..eed3c9d81ab 100755 --- a/t/t5546-receive-limits.sh +++ b/t/t5546-receive-limits.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='check receive input limits' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh # Let's run tests with different unpack limits: 1 and 10000 diff --git a/t/t5547-push-quarantine.sh b/t/t5547-push-quarantine.sh index 1876fb34e51..9f899b8c7d7 100755 --- a/t/t5547-push-quarantine.sh +++ b/t/t5547-push-quarantine.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='check quarantine of objects during push' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'create picky dest repo' ' diff --git a/t/t5606-clone-options.sh b/t/t5606-clone-options.sh index cf221e92c4d..27f9f776389 100755 --- a/t/t5606-clone-options.sh +++ b/t/t5606-clone-options.sh @@ -4,6 +4,7 @@ test_description='basic clone options' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'setup' ' diff --git a/t/t5810-proto-disable-local.sh b/t/t5810-proto-disable-local.sh index c1ef99b85c2..862610256fb 100755 --- a/t/t5810-proto-disable-local.sh +++ b/t/t5810-proto-disable-local.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='test disabling of local paths in clone/fetch' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh . "$TEST_DIRECTORY/lib-proto-disable.sh" diff --git a/t/t5813-proto-disable-ssh.sh b/t/t5813-proto-disable-ssh.sh index 3f084ee3065..2e975dc70ec 100755 --- a/t/t5813-proto-disable-ssh.sh +++ b/t/t5813-proto-disable-ssh.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='test disabling of git-over-ssh in clone/fetch' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh . "$TEST_DIRECTORY/lib-proto-disable.sh" diff --git a/t/t7409-submodule-detached-work-tree.sh b/t/t7409-submodule-detached-work-tree.sh index 374ed481e9c..574a6fc526e 100755 --- a/t/t7409-submodule-detached-work-tree.sh +++ b/t/t7409-submodule-detached-work-tree.sh @@ -13,6 +13,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_expect_success 'setup' ' diff --git a/t/t7416-submodule-dash-url.sh b/t/t7416-submodule-dash-url.sh index 3ebd9859814..7cf72b9a076 100755 --- a/t/t7416-submodule-dash-url.sh +++ b/t/t7416-submodule-dash-url.sh @@ -1,6 +1,8 @@ #!/bin/sh test_description='check handling of disallowed .gitmodule urls' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success 'setup' ' diff --git a/t/t7450-bad-git-dotfiles.sh b/t/t7450-bad-git-dotfiles.sh index ba1f569bcbb..0d0c3f2c683 100755 --- a/t/t7450-bad-git-dotfiles.sh +++ b/t/t7450-bad-git-dotfiles.sh @@ -12,6 +12,8 @@ Such as: - symlinked .gitmodules, etc ' + +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh . "$TEST_DIRECTORY"/lib-pack.sh