From patchwork Mon Feb 6 23:07: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: 13130741 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 77A1CC05027 for ; Mon, 6 Feb 2023 23:08:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229964AbjBFXIQ (ORCPT ); Mon, 6 Feb 2023 18:08:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229952AbjBFXIP (ORCPT ); Mon, 6 Feb 2023 18:08:15 -0500 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E85640F6 for ; Mon, 6 Feb 2023 15:08:11 -0800 (PST) Received: by mail-ej1-x630.google.com with SMTP id sa10so8334102ejc.9 for ; Mon, 06 Feb 2023 15:08:11 -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=/iqFSSifn4UPk6v9oOvXUYaTvHyRPrUUBXbNLpi+/f0=; b=jSCYmX5N7A8L4En+QUQNltknXJ5CORyvkhw/Pyu62eeVBWu1StuUswirMFhBK2U8TF Y0s3vPUM46mo2RdqB7x89e6BhYzCv4h+pu/k4Ka+7UlnB0cWBrj1ipZsD/9010UZV/br fGHJ9Uu4CVB4EmbfQSuqr8QwRSP3FrRxnZd7GXvGK6H2A1cwo6XOpQ2GXROcbJ2ueuBC AziejZqLzlVWYDN5vBE3NZbZenWX47+xXUsr7hf0H50K2Dk3lBPQ5jPJ7HNeJgL6Cw1a 67iuRMJoITT8W8O6oPH6VjRQ5FjlUPblLWZtEkRVL9CLiXe/rg+B4BC8iUFnqU7zchcA CtQQ== 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=/iqFSSifn4UPk6v9oOvXUYaTvHyRPrUUBXbNLpi+/f0=; b=HXf0BS88kv6s+v5N9PmTss3q78YT1nrMkCGKCp+WavpB7u0jGwyhcaBPZxgDlMN1R0 yPzEsgz4CbluGBrnUqIXs58fmtJ29XleG0sB2s0QU211FlLk8cNRwHJp53xIHjG6cBWe hrGk3ej16VjK5bnjph6J8kxLd6aAz0AvK/8GeNrXbSV3ZXS3jgPO7vLaoLOeHtVwy1bJ R9Tf9O47ESNcgZRoj3JCzPFD4DdsdNjZvH+jxAmAzJJN2F1Pdij6bZln0/KV5fjGdN6K db03dtwIlaWRissOGrRFJjw7e78PfqqqbnmJA9vnUk+bAq6ww+q/43RjV2XDNwGuqfVg JboQ== X-Gm-Message-State: AO0yUKWbdECO78ODuPvtDXnDty9bpU5dZOL3TXbIUFm+KP2jutJGPdVG Wm6mJiD5onwJNqdQknbV8HHwcqQ0uWtQ4Lsm X-Google-Smtp-Source: AK7set+bTgjbcbK73helGJ07fyDSCeNqaHwPzlBmXmbdIPgbCTKAjK8y0nEidiLnYb56m0ZqFdC0pA== X-Received: by 2002:a17:906:ca2:b0:887:7871:2b2f with SMTP id k2-20020a1709060ca200b0088778712b2fmr1072456ejh.61.1675724889556; Mon, 06 Feb 2023 15:08:09 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s15-20020a170906a18f00b0089d5aaf85besm2673586ejy.219.2023.02.06.15.08.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Feb 2023 15:08: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 v7 01/19] tests: mark tests as passing with SANITIZE=leak Date: Tue, 7 Feb 2023 00:07:36 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1425.gac85d95d48c 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 Mon Feb 6 23:07: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: 13130742 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 705D6C636D3 for ; Mon, 6 Feb 2023 23:08:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230007AbjBFXIR (ORCPT ); Mon, 6 Feb 2023 18:08:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229899AbjBFXIP (ORCPT ); Mon, 6 Feb 2023 18:08:15 -0500 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DCC7658A for ; Mon, 6 Feb 2023 15:08:12 -0800 (PST) Received: by mail-ej1-x629.google.com with SMTP id e22so9425571ejb.1 for ; Mon, 06 Feb 2023 15:08: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=1qaB6QyMdYM0ttC5FZue2+oQbcFA4V6zAni1aJXFS6g=; b=eZ+sUta1D90ezdx01v2fJ8c/vcvHIXmoSr4ozbWExz12j7PbgWa1IPKkRFuquV94aj nUQDTr6tKgWenZFBHnl810bWD8G9yUXHNWAZB4IwsTrpFdZ3uzYrkpU+TNXbdYsNa8rc h0Bdqz/9rKGJKgqY3Cma5RYGCVtsuXPGn9y5L8yq/1CexATdT0VoBGDxjNCs/0idLFuT CO3I6KlTmTrxtnQLrlwJ63TALd1Ak+ATU9uMePNw0hei21esMZhdPyhbjnSfh3+CJxaF CZEPzB7BWhXmwyd05aIr/6QmSs70QCIdL2ZrTQb3OsBh8eupziYupbz6g1+my6MpkIDz ggiw== 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=1qaB6QyMdYM0ttC5FZue2+oQbcFA4V6zAni1aJXFS6g=; b=VVHAQIeYUOhjRw4h8OzFAbka6I4kfB6bdXYxPw4SsluCi9xw8GSE+1W6DPLCifhkHN vly8jUETY/aXINx1LzSpoUG34PQXYACCgNROOxuJYtJToIdhOy3sHpuMZqPBJoRNa786 DyB65DbMmmAKv6+2bJR5dkG9vo6jfWqSFUIhoBfWZXgQfld6Cc1poEwV8qwzFBwxBW3Y ZnF8HNCoVIy0JavFpnq3YUDGz5NNcqiquByTvHglvUMqHBbYgo67FPt5e4W/mPqouSYs rzGOtiEFDZ58ZcfntCNbueBm5pWfqxOFmfWitvlRUXVNDyJDtVniIhRf7zr6t5cFwTRx WsJQ== X-Gm-Message-State: AO0yUKVmsInv05GG5+iD5nC3kU1nIPh1AGk9ddbjMvdTu1EidvuSd2DR n2wq6TbwS4TIfLNSOUMXPWmjyxhEFt5erAea X-Google-Smtp-Source: AK7set846zYfQIkU4hw7h4K8NzLDE1Q0RYx0xYGr9IAPeXs3z7NvBNIxi90zvZLZI9tqjGpDbsXYbg== X-Received: by 2002:a17:906:a0d1:b0:883:be32:cd33 with SMTP id bh17-20020a170906a0d100b00883be32cd33mr1132924ejb.35.1675724890686; Mon, 06 Feb 2023 15:08:10 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s15-20020a170906a18f00b0089d5aaf85besm2673586ejy.219.2023.02.06.15.08.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Feb 2023 15:08: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 v7 02/19] bundle.c: don't leak the "args" in the "struct child_process" Date: Tue, 7 Feb 2023 00:07:37 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1425.gac85d95d48c 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 Mon Feb 6 23:07: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: 13130744 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 D3A4EC05027 for ; Mon, 6 Feb 2023 23:08:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229548AbjBFXIV (ORCPT ); Mon, 6 Feb 2023 18:08:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229953AbjBFXIP (ORCPT ); Mon, 6 Feb 2023 18:08:15 -0500 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2D347297 for ; Mon, 6 Feb 2023 15:08:13 -0800 (PST) Received: by mail-ej1-x629.google.com with SMTP id hr39so9157767ejc.7 for ; Mon, 06 Feb 2023 15:08: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=PKgNgTEMH5UV/souo70w8ddn/zIWhZuap7B0+j1e0EU=; b=JP2dxiju1IZH5Fe0cR7u04lU+r1t9MNTkjpKmNiGM5f0J+6n6RK4J61tBgDO1e563f JgOk64WbIX8tM1gxuuE/14Sw6bg/qBXlhzeOlEsgIp68cgiuvI86g7G2jSU4eanUyj1X hty744dPTlKTqsl+ewift6INrcabYx7jfDKeokhRtQ87TrYKpKXFU3B6hZRcIp/nmwL7 4cG+5qgHCOwv0fE8rKnDcMb87n4dO/AvTc02PxfR+IZwVY6uzKWQgfK9NTzjfee+9n2i 8oOig2KcA2FBQzNlx0YSLJTRUZxF2FASAQQdcYZ3TDM4PEs8MAx7/Agp5Sti4Rh9tIuM bWhw== 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=PKgNgTEMH5UV/souo70w8ddn/zIWhZuap7B0+j1e0EU=; b=SdND65HrCR4uZf25aWkr8hEZvbdmurwWYhQOlZjeerwhkK8rBPz5MqJN2ohbgVSOGP wNMJhdEyi+1D/LMwmFkLtjCJ6r3apr3scu0Y+zVulP2nD4aRcruV09HHM2vBFmh8Xihv bdpg0tyJti0hA2/rGyvXtQyJ89J2Tt87aIkU76N6aJvZo3q5fg1AkgaGOqRUuyv3PAdM Zn1GwYIytUaEjgtbxU62qOH+W5XzGL6Sg5SeZkZKeNnHeB9rdX28pz1dTKgmAicd8G73 XkzZRzJDilYAF4Jt+v3BFaHmbVGRshEcMPyxK3G602xQ6Eu/B6froiU03qxM6Cv8c94n /owA== X-Gm-Message-State: AO0yUKVjVYDzDQGud5TcAyNw22KIJj8CrADZzH8Mg+pYjO8aAfqhCMBT QIui/Wsn1FjOINg1OLX89gWkrV+kkpcI3bbi X-Google-Smtp-Source: AK7set+pUled7JbNLNOoFJ6vPirI+Uz3fLvNshOZdT7BN4CAzgdkeyCiq2eMg/pWl1aE49uEMCwQkQ== X-Received: by 2002:a17:906:f56:b0:88c:5a80:a7bb with SMTP id h22-20020a1709060f5600b0088c5a80a7bbmr1110649ejj.6.1675724891740; Mon, 06 Feb 2023 15:08:11 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s15-20020a170906a18f00b0089d5aaf85besm2673586ejy.219.2023.02.06.15.08.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Feb 2023 15:08: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 v7 03/19] commit-graph: use free_commit_graph() instead of UNLEAK() Date: Tue, 7 Feb 2023 00:07:38 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1425.gac85d95d48c 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 Mon Feb 6 23:07: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: 13130745 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 8D501C61DA4 for ; Mon, 6 Feb 2023 23:08:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230106AbjBFXIX (ORCPT ); Mon, 6 Feb 2023 18:08:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229498AbjBFXIQ (ORCPT ); Mon, 6 Feb 2023 18:08:16 -0500 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDF743AA9 for ; Mon, 6 Feb 2023 15:08:14 -0800 (PST) Received: by mail-ej1-x62e.google.com with SMTP id p26so38646166ejx.13 for ; Mon, 06 Feb 2023 15:08: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=HvmZTFgi8UGwvl/FXYtEpG1oyYexMCgMKhW+C8nm/F8=; b=d27p7j4hp2A+Moo4/ZrbUnjKWUOzPp7TTbSrpn7u+oniFUC65pWAR1f1yS5fZxnjAr 6cWkYnAv+/rYGRcMCE0nAob9QdkTUD3eT7XvT+WVp1dHFsJQ1Z6pI45d7bzKXPj64KEh Syjqr0EAaXv4xu42Md/IvG/JLX+L1gm+Szg7IF16kTBxJz9UtMrQGKXxWyDUpladoM9i bvQzdCyLUTWf5nkycxx+yhN/CvOxkQxUEkCILd9Gm/q0ad0TtDULheBtU30tZ15ySERc v/F2Y23Iqbykhd9mzkNsfk9d2Z9GRAx+3Kq5TY4BkiN+yuPrkjRzeH1ODnBaUlFU80ur 0FOQ== 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=HvmZTFgi8UGwvl/FXYtEpG1oyYexMCgMKhW+C8nm/F8=; b=fo87tQ1/jSCD0FcQZiL0QEoZHJksgMzneM1iOz0jGkUfEqhStjVipDHdYhfCCMpi99 0x7calLms3EHI/8hJFr5RmEv0lUJLRvzP/sjYU0XGYvCK74qMmQxxkxSyyfuVHoNSeFY Xc12UqhpbvqaOrlT9QT2Y6fJKRbvl4pY8czpdlmSIn6/pSN24LW1pNqf2Oo2hRBKsblK 9PvnIZzv6esT8603WO/ZrL5ivbHwPzfTdKrO9w24gQ7Vc02UO9MKv3+Gwu7mRg+5WbWU geEnX7VI/Ip1qCOhHe+y6Z22ejyPYm5Arz4k6xY9sKB0t3tKzLOdwcIU7/wyqTUjlQZc 4r+g== X-Gm-Message-State: AO0yUKUoBFwzPvlqU/1WdB4RuE/kWAikAoG3UGiTKiP2s+DoezdylVpn pBOXO16rS3G8wMid4hYW2FI5sbY8Z9De7Yrg X-Google-Smtp-Source: AK7set9jfn+mW5T+j5pnVg2Az7Fhoialqh5WRZhr/hlcsN9XzggsgYqVFEZfaVvxs1aUSl69PtqFcQ== X-Received: by 2002:a17:907:9484:b0:878:509f:798c with SMTP id dm4-20020a170907948400b00878509f798cmr1370015ejc.4.1675724893003; Mon, 06 Feb 2023 15:08:13 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s15-20020a170906a18f00b0089d5aaf85besm2673586ejy.219.2023.02.06.15.08.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Feb 2023 15:08: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 v7 04/19] clone: use free() instead of UNLEAK() Date: Tue, 7 Feb 2023 00:07:39 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1425.gac85d95d48c 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 Mon Feb 6 23:07: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: 13130747 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 673CFC64EC6 for ; Mon, 6 Feb 2023 23:08:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230165AbjBFXI3 (ORCPT ); Mon, 6 Feb 2023 18:08:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230018AbjBFXIR (ORCPT ); Mon, 6 Feb 2023 18:08:17 -0500 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03D925FDE for ; Mon, 6 Feb 2023 15:08:16 -0800 (PST) Received: by mail-ej1-x636.google.com with SMTP id ud5so38772892ejc.4 for ; Mon, 06 Feb 2023 15:08: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=APRbMTW3vWoQPqFf+DhkkGBK2M2T9CDlZxiMV3PEETc=; b=Nl3DMqWtxOr+JkYAVTwxZMrhBF2HZZrWSo1wvsnLREcEbUAAeIKG5FWaRg6foSQF95 0tVdZvshquDZkoypyE65mU7UoxUaOMu4VAJCqxsFVfXYC4U7Sr2vLVQTIqIYymphT4fW LHVl3/DSYvHhEqcpOulgykjP/OpgqlccvKUKuVdIL/ZX2biy8qGB0EmbB85Jw14W3nPy tQkOxg9Nw+2RGG8oybTjUYtS4WKITdc6YjwlhjPCIj3emVs0lAvJI+IH7bfoDzDAGv6T F1hhBwUPQj8RGPWL0pW7wBz1X4Xtiat1CD5MK06YcjC+OkuTN4GF/MsDAO96nrzaJkHo rWew== 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=APRbMTW3vWoQPqFf+DhkkGBK2M2T9CDlZxiMV3PEETc=; b=ddB1Rnpgr73Pz89hLlnDK9+FAE7xYdJ+c0q5bn971FAielBeMyOd40qNNLU4WZlAoi SE/zCEAvAPwV8d3WBdEYia70nW/ldh+lqRJaCP9gRwVZSR9Ucq8C4i5SQ+bCOTvYNctA CToer6Cv29hyixC1aYswv5OO19z4Jw4brBe5360873t4RBPVdlsIteniZzVQpc0JcgeP Mgs/xhrTUCLS/eNX6qG/Lt6He2EiTgJrDnYXKigjHdBZkLp8IsV0CwNM3OdvOvfRuOs4 KGtU+n6ZtYLJUg9+6o1WznskrGWStGnbbvB8vCW4t7rWKBcukJ5Styu/RSlQZxAeWuuT AR1A== X-Gm-Message-State: AO0yUKVVQOBZWGcM09em2yue6o7ChNbUaIWkPtqxlZpsggpiAffxXLlM 1+rQYVNE+1xYK0DEXIA3XvrJZJb9DrJxRoqo X-Google-Smtp-Source: AK7set/Ft1/nfNuQmjxcopLZAhYWv8bvTu9iDWQn6Lnhrphega3D6ixBj3pthZbPojmcuIiMDRG9yg== X-Received: by 2002:a17:906:4a93:b0:88c:4f0d:85ac with SMTP id x19-20020a1709064a9300b0088c4f0d85acmr883053eju.77.1675724894044; Mon, 06 Feb 2023 15:08:14 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s15-20020a170906a18f00b0089d5aaf85besm2673586ejy.219.2023.02.06.15.08.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Feb 2023 15:08: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 v7 05/19] various: add missing clear_pathspec(), fix leaks Date: Tue, 7 Feb 2023 00:07:40 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1425.gac85d95d48c 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 Mon Feb 6 23:07: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: 13130746 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 BE2F5C636D3 for ; Mon, 6 Feb 2023 23:08:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229936AbjBFXIY (ORCPT ); Mon, 6 Feb 2023 18:08:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229994AbjBFXIR (ORCPT ); Mon, 6 Feb 2023 18:08:17 -0500 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02F5040F6 for ; Mon, 6 Feb 2023 15:08:16 -0800 (PST) Received: by mail-ej1-x630.google.com with SMTP id mf7so38748220ejc.6 for ; Mon, 06 Feb 2023 15:08: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=r32YOUi3/hD2J2xHGNU5MLe3BaAzvTq1alLQHZ/oi+0=; b=Y1MiG/2bTbQCXufFAyF08qjUFh/0rSuiNUbWgSY1Z9PbWrASepXIMMZTUtW3SO7UKJ 9LXXX0aJaXgNgbh3uM43v9Y6JZcjQrKqrciMNXuqJtD/Sr2VEOFSU5sDvCwpXELxGKSZ MKRq/tWhIKXrcEVeScIKmKojpr0u0WvY5T5m8x04m6o5VdDdAk0a45Gh8vN3si3dNWz8 e15a3a5xfM17U3P82vlWipDvvvLSYUzSbHNaC2PgfB3bNTjV12DiuGMIDa6dLQaZzQjo T4yc2spqauCBqAKpE6+VARUXxG2A1RAaNxntKo+1Qs0o37AYzfMRQtPa5GwkcA/4EsOG RD1Q== 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=r32YOUi3/hD2J2xHGNU5MLe3BaAzvTq1alLQHZ/oi+0=; b=QfGDda3+f6/ymj5yUD+/vZJuiZL9r5V9E8Y1iB2GKgvf1P6Xap1YuwThj/TxiPFWwu C1VMgBbjG050L2vm67oXboA63jS+wuQyZDaQZQ/3Eim9wNokKq4dlElnoqNpuxJ7YxSS UfR+XYx1UTRP93+2gq8O81MAy6sz21Qky2Z9N124MnzAdBBwAh4yLVRoE/uBhpFpU1VL 2bOE921QbN2pbUwqsPYGkzAaduR9v6J0HWGZIZqyLrtCVXpIVaHpqP7n0eeyQN5XJI0v cIu7lufnPy6vUBNBbtgjm2dwP4WMY40+Hl7xf2KdInNs0hKUo8FKo+rdesjyyBmmmBe3 Bjpw== X-Gm-Message-State: AO0yUKV3jQXEY/mgXhyF8KmrmWqu3z1XHQtGzVwiWdf6O2Rr3gLL/lVc YcH/EwKkEWJn7Vl54CPCXH5YnwWVq/fdkaKR X-Google-Smtp-Source: AK7set+GbmWA8ab4AB4i5GAslFJMKrJFatH1MwKt19HQe+JPsie32HvfyfOA+3erwC96ucRyCeNo5w== X-Received: by 2002:a17:906:a255:b0:7c4:f8fb:6a27 with SMTP id bi21-20020a170906a25500b007c4f8fb6a27mr1446193ejb.0.1675724895220; Mon, 06 Feb 2023 15:08:15 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s15-20020a170906a18f00b0089d5aaf85besm2673586ejy.219.2023.02.06.15.08.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Feb 2023 15:08: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 v7 06/19] name-rev: don't xstrdup() an already dup'd string Date: Tue, 7 Feb 2023 00:07:41 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1425.gac85d95d48c 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 Mon Feb 6 23:07: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: 13130748 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 1E6E2C64EC7 for ; Mon, 6 Feb 2023 23:08:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229632AbjBFXIa (ORCPT ); Mon, 6 Feb 2023 18:08:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229992AbjBFXIS (ORCPT ); Mon, 6 Feb 2023 18:08:18 -0500 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 015CD115 for ; Mon, 6 Feb 2023 15:08:17 -0800 (PST) Received: by mail-ej1-x629.google.com with SMTP id e22so9426074ejb.1 for ; Mon, 06 Feb 2023 15:08: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=16usFGyP0ajFKYXwj/IxBiQNbrTvGcu2basqJ5/37hc=; b=MnEQCryRBRGAN3hTHYKvwcaNKVkWofa2ORUU0PXcNyYArhQqlo7fKU2/esIAXq9+2s qAcnZOtZ35SGjlmWZRMGqnJb71uDr4vnCAuqf1PNnelo287KyZe3X6QEM7sQe9XL3swM sncXWMEmnPlhbK5U4A8H5cKI2ru29aQS3Eo2jWVwV2+d7il4QxxEJqL/8mBmXJxYFpA4 mEm/pV+PgReJ/IKsh5V5Zf5J/eWEb2kSANF13g/WDlA+1DrgpzfCZXA6q2KEVsdaFl/A QDoN6snAvsG02X8+ZpV30HLFs/xXxCRX9dvAstji6q7BxLGB8guLquGEUPdvZ31rcZnP ++Zg== 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=16usFGyP0ajFKYXwj/IxBiQNbrTvGcu2basqJ5/37hc=; b=PWIj781eGU1TuqlDUyvwEqrPsKZ9aSJbynA/wCryQ10IfADDeKeJ9yuXgg+qlYyXkJ UjbAHl20/VUwZbbY1dKrIjAas9V4/rE6MqfVLsAaNq5A0cgn5/eX9skBi3OpJy61o/O4 iyAQcOKi9C4RW+bWW2F1sggxnzqEgYerTKcrXDIp9b2V1mTGpx+SWWdUI8KUnzBkA6YI h6kgJi258p8Bl8rFNhJ7lAqeN4TrEyaCK2HX8KmR/dGctIj8zDE+Kd7vkQWezGapuqud xb69NL8tbOMVkNfUkSGsSTfPsS3efupFWzWUtFKH9U/sNHp5swHtR/6saeOxKF2sfEjB ipMQ== X-Gm-Message-State: AO0yUKW2s2FcYOycUpyx7Wn5lmpy2/LVuniDVhMXYs9omDn61SiS0SkP fuLSHcgYPBTaYCz59UEiX98lhjNqS8bdm6pe X-Google-Smtp-Source: AK7set+cB5qf6rxiZQ1PSvGh3/sMK1z0WgMrjE4NN2z7KVx9aZrRI03FKgomx8neNw4/QdTdZ01TxQ== X-Received: by 2002:a17:906:6b8b:b0:879:2a5:dc40 with SMTP id l11-20020a1709066b8b00b0087902a5dc40mr933255ejr.76.1675724896176; Mon, 06 Feb 2023 15:08:16 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s15-20020a170906a18f00b0089d5aaf85besm2673586ejy.219.2023.02.06.15.08.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Feb 2023 15:08: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 v7 07/19] repack: fix leaks on error with "goto cleanup" Date: Tue, 7 Feb 2023 00:07:42 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1425.gac85d95d48c 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 Mon Feb 6 23:07: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: 13130749 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 86D6FC636D3 for ; Mon, 6 Feb 2023 23:08:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230183AbjBFXIc (ORCPT ); Mon, 6 Feb 2023 18:08:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230037AbjBFXIU (ORCPT ); Mon, 6 Feb 2023 18:08:20 -0500 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 122065FDE for ; Mon, 6 Feb 2023 15:08:18 -0800 (PST) Received: by mail-ej1-x630.google.com with SMTP id sa10so8334718ejc.9 for ; Mon, 06 Feb 2023 15:08:17 -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=PVmLRxCQHtu74AnHvtfKqLTTuJHmqgO3lzJFe3ovMHk=; b=la0wcpnjz3k8cWnMcbnvNgOap6AlSOfBLjIjb3PswHELPNj8c1IYqoZOtOIBe1yJKp MBrtB3/+91W9JX7ERBH7d2GkLpZFuSr/SuCk2p+r+nnAH8EGXe4PZApDABNaLvyJkgnU bdFEOdhpxq8VLTxmWhBJDPK1AVfHW5wBXp81NXl9QD5BG/ndnFr2mlYrU9LyB4tthsms CWXB+4DSjaO1z/ugO2KaVoXZeKG381OJGlN9NDx/axFwLCFMDfQeDATB7xvKWvmfULEB MsieSwp3mMIeUoS2w/UKTXuUHUfd5LYylQqR45u7U6sxiLwtJ0FcRofSVb+cd+xAApfh upJA== 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=PVmLRxCQHtu74AnHvtfKqLTTuJHmqgO3lzJFe3ovMHk=; b=6utyRS9RbifwNF6/Yf+igg2ZUd7C3B4Is/BtjX7Y9w5SOk0DwhvrXbfykJ+NY7skvQ U+qd4+ugUj/kplEMyo219JiTUxoPjdAvTnX1CDFm9m6FQIts3DtygBBIkwX0sqNVnZgU S/hBmGzXafj8IrxEJKyXzpH7GT/3IWxAx/CDoVUsiL/Hhjft5mXK2gcp14+ThU23F7x6 f0QtonViP1/ZbZfR57LnUc/jKKb0UKYcT/o+l5X+Xm40ByizFer0Q8j2AbEbWyBmU5cv Hx/goATGcxhJ/Mc4pDec+TfkkCdg/mNVcJeyN2LPQEypRfzbRTL63z0W6oJWn4yN26DW QYVQ== X-Gm-Message-State: AO0yUKXb203fPiCow6NJJvB5Z13bA0zL3qn+7pPrf9DewGX1dIfu+jTm vbNKhlDM1eSeHmMTRy5/PGwRU56TbfSwrEXf X-Google-Smtp-Source: AK7set+5RJr0nFo/m6ZYFXOOSqsdOO0whoAhyXzjI3T6wMtiP20NDv7zFd5b0CEvGFES5LiYP/X44g== X-Received: by 2002:a17:906:af6a:b0:88a:7408:384c with SMTP id os10-20020a170906af6a00b0088a7408384cmr1069783ejb.47.1675724897303; Mon, 06 Feb 2023 15:08:17 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s15-20020a170906a18f00b0089d5aaf85besm2673586ejy.219.2023.02.06.15.08.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Feb 2023 15:08:16 -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 v7 08/19] worktree: fix a trivial leak in prune_worktrees() Date: Tue, 7 Feb 2023 00:07:43 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1425.gac85d95d48c 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 Mon Feb 6 23:07: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: 13130750 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 D93A7C61DA4 for ; Mon, 6 Feb 2023 23:08:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229910AbjBFXIf (ORCPT ); Mon, 6 Feb 2023 18:08:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230039AbjBFXIU (ORCPT ); Mon, 6 Feb 2023 18:08:20 -0500 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA77A30EA0 for ; Mon, 6 Feb 2023 15:08:18 -0800 (PST) Received: by mail-ej1-x629.google.com with SMTP id e22so9426233ejb.1 for ; Mon, 06 Feb 2023 15:08: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=A8mRbRkuojhf/gN9c7/0s8do/Iwdi7TUUbli2Iwy+Ug=; b=m1SXSgAe6zv5nuWpqGvKuC5W739Cc7SM6HCHecUYXw9NofTDOi+Y282CU/r0mvOAfF dhMAv1WaLSyYvNB7YeJwmamV+uQhbP/2cc2pjRSjqxyWpSH4WWV1jI5EWHMiK1ngYtXe vSK+MDFYZUX9XJFIvk6kAo1mhANFjgVcOS5nJhOBpyaClU/pmxwaxxDyaXutDe+q2O0d PUQAy5e8CssWub4PVB9W9oy3FwQo7C0lNYTyKYkbxmvrDa7QBmZpIDdCSjOqlb9FaUzI 1h7DYrEVbPuJR2K7yoL/4S3SnmpWdaJa/FHcKAQUvX0zIEiUszxJDXxsLH3lSOlrrIPz 8RMg== 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=A8mRbRkuojhf/gN9c7/0s8do/Iwdi7TUUbli2Iwy+Ug=; b=hpZmuqNfrhLNB30cQH6NnHqAi6D+NIte1tPr7BCsDCLcjdoomb5qWDouONP5oG4uWu kcBAdER6CpVphpPFlCGqBUqBNbp0ssp4SIDVbI6bMFar/Re/soJooVB646E5XwmiVw7Y P9A1XhhZYifC/R9jrehYiJBI4vkdMvHgK5Nfb7rRow1jQgC5WEJ8KWrcdpV5423HhwyK sBb9ailo/I0IUkMncLokzdrEJll5EUxgYYuvE5YgOTaZ9wd2EqBxunI/vC8e2JO4GBGX qY3IG/tHSwuSiHp9tqMDkdaqpKh8z7pgpyNNWE2nQiCXVY8FvKNZ3gqFcNp5C8FTMrPQ OSbQ== X-Gm-Message-State: AO0yUKXJahC9BF0tQYm2PoJvUzMrEulT/KVhdPpI4OjzxjuwUj7OcFak 1EkftNvoRruD0Nk9oKNb92+ZUngwSNFXgIhI X-Google-Smtp-Source: AK7set94LPC9W6Q4UMhPy7oqKWAPaXUgLgI6AIwFa4ozc8oTyKrAnevnb+PAlqukaDFDe+H+GOXO6Q== X-Received: by 2002:a17:906:824c:b0:859:1d78:765 with SMTP id f12-20020a170906824c00b008591d780765mr1130589ejx.11.1675724898208; Mon, 06 Feb 2023 15:08:18 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s15-20020a170906a18f00b0089d5aaf85besm2673586ejy.219.2023.02.06.15.08.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Feb 2023 15:08:17 -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 v7 09/19] http-backend.c: fix "dir" and "cmd_arg" leaks in cmd_main() Date: Tue, 7 Feb 2023 00:07:44 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1425.gac85d95d48c 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 Mon Feb 6 23:07: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: 13130752 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 E8918C05027 for ; Mon, 6 Feb 2023 23:08:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230232AbjBFXIs (ORCPT ); Mon, 6 Feb 2023 18:08:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230167AbjBFXI3 (ORCPT ); Mon, 6 Feb 2023 18:08:29 -0500 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 849BA31E3F for ; Mon, 6 Feb 2023 15:08:21 -0800 (PST) Received: by mail-ej1-x631.google.com with SMTP id mc11so38696552ejb.10 for ; Mon, 06 Feb 2023 15:08:21 -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=2KNedtb+kcuqOHdIPhSqYUKAnp7PxCIkOe7K81k0HZg=; b=W3DZoXJGDgOyAQDuzUREQfP+Q5WObKmyG2AsA/gLf9tmKYpaDeci8tL0+a703EgT+L alDMcwlZTEFFjnyvrzDi5I+zF/eg4NC045i5unBoaE9lv/Fm2BgOlVGmt4JJkS0WaW0n f5KZEjMarCHv4oQ6RoC6A2nDXkSp8APZZW471OMXOV6287qMK1nmWUB+qxUajmXqC+VX zCCpQuqLSh1T8ynwk0lq9N72D+p7wjO66KW0tqT92a8Htm9oBLblFyvtiTmmIB4AWzCk KeEpE4jJTuZKmeIC82oCW0sevVspcxHkYzlLrt9vwy017zCkgU1YDPgXJwKrLmg1l5DY bpHA== 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=2KNedtb+kcuqOHdIPhSqYUKAnp7PxCIkOe7K81k0HZg=; b=bi21Y3f48M7F5gl+omIAW+vGaASAjJAJ9Ph5WrQP5ajrR68Vwu1DsLVZzB/e+aSfud OJFx3EuaPAwiTow/3o3I3e0ovW9MVX/WaCIC5ZEnoquNLaLbqgwSijbKwAnvBR9+SW5O 81E+PIRPqt5yvEob7k6+0o/w01BZ9vmZF4+O7vWvV9+T+MlxAKMiWrntKQg0F16EDW7m JvcaGa82JWMQDgtgwVbpYPnqs8J+kewjTWkp8/JyCPNXQiYq7S6AXyrNZq1M37Khfjx3 BaUGb1CRb7/l/B4LLATZCIfni0GjUp6q/qZ2/zWd/XOVTWSRX8lzk5BQJ0FUcy1v7znV 86/Q== X-Gm-Message-State: AO0yUKXmUV7AddrnuDADDc0YP7WQWmSZk3PLXjbisI/XEtZ8xylhg19d KKdLHIepSCyGpWIskU2w40/I/Rn2/ozpDAwm X-Google-Smtp-Source: AK7set+GGbWDMmbgU7gWze7M18Rx5kjQDUdILCqgyIQQi47fvpi432/j62y1zyBER42Zbex0VXdK9g== X-Received: by 2002:a17:906:2898:b0:886:9b85:ac5d with SMTP id o24-20020a170906289800b008869b85ac5dmr937635ejd.44.1675724899384; Mon, 06 Feb 2023 15:08:19 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s15-20020a170906a18f00b0089d5aaf85besm2673586ejy.219.2023.02.06.15.08.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Feb 2023 15:08:18 -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 v7 10/19] http-backend.c: fix cmd_main() memory leak, refactor reg{exec,free}() Date: Tue, 7 Feb 2023 00:07:45 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1425.gac85d95d48c 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 Mon Feb 6 23:07: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: 13130751 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 D893AC61DA4 for ; Mon, 6 Feb 2023 23:08:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230159AbjBFXIk (ORCPT ); Mon, 6 Feb 2023 18:08:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230138AbjBFXIW (ORCPT ); Mon, 6 Feb 2023 18:08:22 -0500 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE21731E30 for ; Mon, 6 Feb 2023 15:08:20 -0800 (PST) Received: by mail-ej1-x630.google.com with SMTP id mf7so38748642ejc.6 for ; Mon, 06 Feb 2023 15:08:20 -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=ZmixHhC7LutftPQ/kAv4923i0unNbfH9yhhc4dqrDYE=; b=qOiBbcYJFIba9cD/iHXkFQg84QAqqnLT4ELCTlJPv4bWgyRNIUgp7+VHfKATGGYnOV vN4729EhSx1jjj72rFOTSXuK9jsek2KgtHYFmkLb6a6m5vRy+s0sK08/6wbFkKUGEl/C j0IbixoKZ/4emRrOCYS6/rTOr/ItrgQrUB+RV/oO0xGmMTgjToud2iDSapmukX//wnyW 9G5vMqw/JxeH/VxMh+j7FwtIB72vs36lcq7homj/uvzoMZ7eNq80LQ7jUpgNxAn+ThhD nJKIyjNwUaIWAY3H8sxgyzgDTmJNxTiiKlzerT1vF++hJsYmQ9Uyi0FD15ENfhRFB00g 9Ohg== 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=ZmixHhC7LutftPQ/kAv4923i0unNbfH9yhhc4dqrDYE=; b=u3WF05koA0hwKX+VkmEXEy7XZL5DsBlkqGCPoK5jwbMhE67IxEwjC7K6TFKs9ebhZh kd9h5LurAhRxcdoXQG6bA0dpS0CQCcTbeNk5x/kZUuZ+mbendsN+YbOs9+D8D9xzYOWJ EUkmgEAZfHCtUhRJzOmdF24kA2hINDiDVse9mExGC337tbS4mkHpICDf1mywKu0azUC5 FitbaOaEkedSQXLPcOUItMBjxyYQaRvv4lO7rqeUy1Rew7dgcU6eIgm4eT5+65W3FPOd gpUihqdIbwYjsFKeRhpb0ZTSrx+Hp5BsYiRwwu2AyPT5S22JSOCRWfMTGt/O1jC5BNSl Mwyg== X-Gm-Message-State: AO0yUKWiJrZfxW3Gkoof3hZ556jBMsbieR1ImEzwqRTZWCkTTY1IIXxI fJxu/O/w4YyPRdI0Jq7RGUtrrp5aqBRVM0UM X-Google-Smtp-Source: AK7set9G7yTbMFhqz/v2lHNKPsQzzOG+m2zbuk0T4+0G5/RegSEnx87futAeR784K6x9QakYlwcbYA== X-Received: by 2002:a17:907:8a03:b0:7c1:458b:a946 with SMTP id sc3-20020a1709078a0300b007c1458ba946mr1433741ejc.0.1675724900284; Mon, 06 Feb 2023 15:08:20 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s15-20020a170906a18f00b0089d5aaf85besm2673586ejy.219.2023.02.06.15.08.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Feb 2023 15:08:19 -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 v7 11/19] commit-graph: fix a parse_options_concat() leak Date: Tue, 7 Feb 2023 00:07:46 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1425.gac85d95d48c 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 Mon Feb 6 23:07: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: 13130753 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 5EBF1C636D3 for ; Mon, 6 Feb 2023 23:08:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230134AbjBFXIt (ORCPT ); Mon, 6 Feb 2023 18:08:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229590AbjBFXI3 (ORCPT ); Mon, 6 Feb 2023 18:08:29 -0500 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E22CF30B39 for ; Mon, 6 Feb 2023 15:08:21 -0800 (PST) Received: by mail-ej1-x629.google.com with SMTP id e22so9426462ejb.1 for ; Mon, 06 Feb 2023 15:08:21 -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=ELbiXgPE1CdT32ShCWrt2/TVzy5K3bEoaY37yU/KgfE=; b=Prq05Kxz1E+UWzS0qrFQ4OM/l9EkAIyEasSN2knIU7GWhAeZro+kPZOfUnNAf4KMt2 bGoyaooO39yClOd15fMyx9Tbu/JmiIkSHPPWgSh8IwfUsozS127W6Zcwqih8XCwcsYLj urp8mli9wJXnqlYPQuJlZV+ZdxZTcYFUIx91FR35B9Cy3t0fMqa5TVWX216YLnH+XUG9 pfHNfDC6lE8QYdshU34iTCE2jXyEywT/3LSBKW/J/zps/+nUkutERdchUH9twG45x/1x 96aa5HNm6jmsVmzF7xE8sAAcgiLY64UpHGvXb5w+Csn0y/jhP/0R8f/fSM1Vgp318SUA 04yw== 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=ELbiXgPE1CdT32ShCWrt2/TVzy5K3bEoaY37yU/KgfE=; b=58YKsUs9LNffkP2AtqXxJ5weV7Hy8PQv+ewIzTTS2iBeqJ0N1UMETUVA5BjZplWQIR +VsTqhzL4eMIT5ZXNy9A7VvPl2lsS0es/7ZvfG5vVbHIAjMZLx0FtHQr5EmLHJpW3pim /czQmaL66rKMLs3/0sukaf+Nv4MOwE0ePeRk5UE2SoYhdlgsXCQhcyYBKa4hu9fM4zuF 1B+svDjBlHhw8HQP0LBwDuseNpi2dAb5BzyqbfuXTK3+Ynvh/z3DjNodQNznixO92hya 5Sqa9qH3oEzNwnNBapth8/oCNihDeneC2ubMyqFEks3Zbadlg1CpSjhIv5O7R/qHHQDf ypzA== X-Gm-Message-State: AO0yUKWuz4t7QiI2RG2iD1eoUVZIcbJohU2V9S8OFyHTAJJTO96mu3v8 Ku5VmchS/ZYos7hnqiOMTPogW9JPReIHBP0l X-Google-Smtp-Source: AK7set8z/fGADo86pk0N6sZh1eRbRr/aiLRVaEx4rcoEU2pHyvNeGNob3e1XwhZJHCR1iOMmyYjIUg== X-Received: by 2002:a17:906:d051:b0:86f:3dfa:4016 with SMTP id bo17-20020a170906d05100b0086f3dfa4016mr1095299ejb.7.1675724901205; Mon, 06 Feb 2023 15:08:21 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s15-20020a170906a18f00b0089d5aaf85besm2673586ejy.219.2023.02.06.15.08.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Feb 2023 15:08:20 -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 v7 12/19] show-branch: free() allocated "head" before return Date: Tue, 7 Feb 2023 00:07:47 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1425.gac85d95d48c 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 Mon Feb 6 23:07: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: 13130754 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 29F13C05027 for ; Mon, 6 Feb 2023 23:08:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230280AbjBFXI4 (ORCPT ); Mon, 6 Feb 2023 18:08:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230151AbjBFXIj (ORCPT ); Mon, 6 Feb 2023 18:08:39 -0500 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E357E32513 for ; Mon, 6 Feb 2023 15:08:23 -0800 (PST) Received: by mail-ej1-x62b.google.com with SMTP id e22so9426543ejb.1 for ; Mon, 06 Feb 2023 15:08:23 -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=r9TikU5Ol8piO7gSFpe+vOIY+Xlo7g1YhRGNfttIxYc=; b=Iok4GXOAsL4Nn3POMmQ6Z4wIhecjDymOeSIwHARUZUpnyIoADCkK1eod4vJ8u2YChS IsDxH8a8OVrbX5FxLw7yox/oQ+v3MaWXOKuDbyWhQzMCoszev8md5uiMBb+IRfA0Gri9 Wbs6bH9tG4lfijaZNut5XuIRQJSC/bibrQRtdDKjkxyY/P0JvnMdFqoqhOvhek95d+e0 r9w26tsvcnaY2LuxfU3+AnqoPMprr2ty0X+jgOR51GXbM1ac8UNXUIjzDIdoXe8afDKp bkyAI72TXUO40L+brtpDtMzn2WZScb+uou5KeEwYQkocgBkbGLz2BgXVc/dbuIBXN4Ps Qj8w== 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=r9TikU5Ol8piO7gSFpe+vOIY+Xlo7g1YhRGNfttIxYc=; b=jaPP4ZEB1xTCE3LbjONgl0d9zbo5x7Cm8ZglIMHeobWCL+LSr/KHIfuvXERpgBRe63 u8NaB8sooO7gpMjdW+eASKYqx96ObP3ygtwZ7k3iVND2Eyywvymxszq72tMNAIWYQRGI azuJue063IabsMsRcqKzN7RCO1Aa4eQcu5duA768YAbdnZcNEH/QdbDnDnbJ8LDjLp4L XL9zrCUBjeLQBKBeS6L+haonFp9qSr5CEhJI0ek84GYXWSrSLI2P+/81/9kM0gUyHm8W 5fvvV2JgxqoL2aw82UKXEWaGs7/gj7G7oTpC8TnrN0wIo6h3dhaj17zBSU12DwJfIGv6 TSkw== X-Gm-Message-State: AO0yUKWzgcjqbYdem7KL73984WzgDIPLej9IWY1UUMlT5tkJTRsnpG2L ZeLkmPaSBm5KDuW4cFAgJMa/iLuA+bFnP3xm X-Google-Smtp-Source: AK7set/Jq5joDAmybzVOkDqSVc0hF237zyTyC/+W/Yx+dtTw87Z1biD1kHWnxr3MrXW1E/Y5hgI9qA== X-Received: by 2002:a17:906:90cc:b0:878:7d2c:6ba7 with SMTP id v12-20020a17090690cc00b008787d2c6ba7mr1166641ejw.62.1675724902088; Mon, 06 Feb 2023 15:08:22 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s15-20020a170906a18f00b0089d5aaf85besm2673586ejy.219.2023.02.06.15.08.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Feb 2023 15:08:21 -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 v7 13/19] builtin/merge.c: use fixed strings, not "strbuf", fix leak Date: Tue, 7 Feb 2023 00:07:48 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1425.gac85d95d48c 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 Mon Feb 6 23:07: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: 13130756 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 4AEE1C636D3 for ; Mon, 6 Feb 2023 23:09:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230318AbjBFXJA (ORCPT ); Mon, 6 Feb 2023 18:09:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230230AbjBFXIj (ORCPT ); Mon, 6 Feb 2023 18:08:39 -0500 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 449153252E for ; Mon, 6 Feb 2023 15:08:24 -0800 (PST) Received: by mail-ej1-x634.google.com with SMTP id m2so38748333ejb.8 for ; Mon, 06 Feb 2023 15:08:24 -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=a9exlaS/vFmmeUI76ci5dvRddAkFcAU2AdM89oCUXKc=; b=GOeVTv+TzV1hJJggptd4UDrtdLEdVpbNva3osHl4a1/SjveFRp0qJrXMdzMOM8EhuD XgO2uzmNFqjyDEQzFMcWmIA2uPniyzN7FcNbsItfaCzgYt0Jn83FkWae/yFoqO+WVMBG PXQTnZqaFdXalBMxneEuAZGKH9UsjGd4fuF4Z0LOo/2aEfuWMMIVR8s0RP8IocyZS7UQ X8WXOSmgu1sX+727vQzYydoWvKiXB58WGTu6gj845YLtJqoyg6FFcWFLyRt6wWwM3pXI sxY8G0M9IC8WW/ogh9vGB2X+GOATtr5xzaf3W+IN2/vkZ1QHb2Ha43pq+JhzKuLCWbkD /fwg== 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=a9exlaS/vFmmeUI76ci5dvRddAkFcAU2AdM89oCUXKc=; b=2IcO9/RlIwbei5PFod3D80vsFEADTxCtmXK2VF/XaKtt/a7Mv9p5B7kWimQd8SuiqZ 8Zvltbs56tk/mf3J1u0gzIfzeKrKwsYaiuFwBJIi7IWrWByiJCYvBvfzuchpHzeS5vgO h8/Ga9oTtNS0DkC7iIkrjFICWYstWtEL+7RYce24whEDSWboqnzfEhbzVPSa/TSZmoN7 NrJjKVEAJZbuTFvu5rJj/CxQIhPpuxJiRv9cCj5XC8GqvsdqAEfMQki/8roxAjnRiXdI N2ofIjo7ylNVa658oGZRwPD8IjBEHBt4M6pPOAanNy58M8h6UyjFzHtCuE6QmJrnAkLT aaJA== X-Gm-Message-State: AO0yUKV3r0wEvtX7dDdyJORpo7NePZvK6IiTFaXqX2Z2kvuUKux8qcvm +vrNjbdpLrg+6loy86nfMhwKZmjMJyDTInb3 X-Google-Smtp-Source: AK7set8X0TPQJo4wuW6jaDc4XrJkjnByF1j6KlQDsnJwAN4bHPVVjpLHjI0xx9IQE+4uYxldleWoEQ== X-Received: by 2002:a17:906:e218:b0:871:dd2:4af0 with SMTP id gf24-20020a170906e21800b008710dd24af0mr1126104ejb.26.1675724903005; Mon, 06 Feb 2023 15:08:23 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s15-20020a170906a18f00b0089d5aaf85besm2673586ejy.219.2023.02.06.15.08.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Feb 2023 15:08:22 -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 v7 14/19] builtin/merge.c: free "&buf" on "Your local changes..." error Date: Tue, 7 Feb 2023 00:07:49 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1425.gac85d95d48c 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 Mon Feb 6 23:07: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: 13130755 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 D9C86C61DA4 for ; Mon, 6 Feb 2023 23:08:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230293AbjBFXI5 (ORCPT ); Mon, 6 Feb 2023 18:08:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230224AbjBFXIj (ORCPT ); Mon, 6 Feb 2023 18:08:39 -0500 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0239230EA6 for ; Mon, 6 Feb 2023 15:08:24 -0800 (PST) Received: by mail-ej1-x636.google.com with SMTP id ud5so38773644ejc.4 for ; Mon, 06 Feb 2023 15:08:24 -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=9Dn+3L6O0etYxRe0KAHTZz8bWV/0dtUxBSOtfhLBO1E=; b=XSHXJStihuo2TKNY1icRnizs0G3vJBsI5yk4obwvpe3EPtjKyznK0dp2REkt/2ABJS 56NAtF4bzns3b4ESt+htA0I/c34lLKFhrV/eY1VXhpg5cQ7BYwqUB1H+gYx+vAMVXWqH nm1viu6+mR4qMTIX8QiV5+zU5w/2mNwpNTW6MIx4eOlT91N1B6iWnxmuI/1XH3QyicRG evzfdbTwHM5pnBAaE5PRHIOG3Lqov10n77LJd75TVub4GnIiSzpGU4SU46vv2eEqX50q CwJdqp8s841m2s4zeLYDLwPsBSQGhiS4Q6Q609EToxwbsMRqjZUrwlLdc/5Scq1mS7oF u+sg== 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=9Dn+3L6O0etYxRe0KAHTZz8bWV/0dtUxBSOtfhLBO1E=; b=dp0nrBAXRd1VvudXfnxetmd3tnO/XZOFcc+X4otIQk2sSXcQWTks1hW/jajOucFO/w cvgnK6u6ag2HV3qYLjLFXxYA4xEKrkYzsYD0ka1CCOSV3eMny/cy9y0jYy7blqC51CH6 czJSvuBZNAklW7mqcYQ+xh+PBir0uJYQy/VShd4CT8M9MzM3sKhAcI5ZTGqKF/LCQ6lB Crn9p6NZYKrZAsrILBrkI6dwgiDWZvzaGQm180yD8e0cBTGRm3OEmAEJTxIXBwliLEIk r+VhzH/XIF6jHIMf6CN06gODcGB8pato43/vqHEpM0yIsbcPjNhkEPNddeHI8LBBqnqF 8xmw== X-Gm-Message-State: AO0yUKUGpTW2ln8RohysLxzaqCauEyB1ks6M1xlJAn1vLPW2gPmoEFJL kzPnKBNEBiuA4ow7f6n8msNeHVH8b7neebYF X-Google-Smtp-Source: AK7set+6z9eBEGKg03h8IQixpSYJbs4tiE648YOGiKtYlUvk4BFgqIIG6GVn59NW8cnYxyNKGg1qtA== X-Received: by 2002:a17:906:3a8f:b0:88f:a236:69e6 with SMTP id y15-20020a1709063a8f00b0088fa23669e6mr1131728ejd.7.1675724903921; Mon, 06 Feb 2023 15:08:23 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s15-20020a170906a18f00b0089d5aaf85besm2673586ejy.219.2023.02.06.15.08.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Feb 2023 15:08:23 -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 v7 15/19] grep.c: refactor free_grep_patterns() Date: Tue, 7 Feb 2023 00:07:50 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1425.gac85d95d48c 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 Mon Feb 6 23:07:51 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: 13130757 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 45713C636D3 for ; Mon, 6 Feb 2023 23:09:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230355AbjBFXJK (ORCPT ); Mon, 6 Feb 2023 18:09:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230244AbjBFXIt (ORCPT ); Mon, 6 Feb 2023 18:08:49 -0500 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E25B32E5C for ; Mon, 6 Feb 2023 15:08:26 -0800 (PST) Received: by mail-ej1-x634.google.com with SMTP id hx15so38654772ejc.11 for ; Mon, 06 Feb 2023 15:08:26 -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=/PF7bzyqaW8jm5FlQ7+3qLTyxZs0RECAcIL3a6+EzHI=; b=Mdty0SzviG8Wlj0ks6l/OEEU726DwnKBHGPajN+SNu7RFlEcR3PfdA/Cs/jjN+G8Ov vMJuTL4L7LJy+egfxdASlHh/KNi4K/6cS/16xSdTPmJPXRbr/aTxYsMMpIMe99wgqc1V BSYfa2UIT+rFqnQnSKgatmX2ffwN8LgaP+VVBizahRMnXfPyI7mWzAaNuECyWJAC7B59 ZBs9hfBQisJ9t6dTZLVJf7a0zrsyhj6SQ4DXh8sVhaATvGH3DTDTTtvz5pjfVF11TlH5 iXbFdEOuF6uNYsoF8ENlfrxhfCeIVD6mTvRJSPjByZKUB93MM5SpwDxU2FmtVx0epjCQ C9Ow== 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=/PF7bzyqaW8jm5FlQ7+3qLTyxZs0RECAcIL3a6+EzHI=; b=hOMUoX0SSN/YENYfn7Xa8tWXUuPQBFB5vpxgxnv8iIXGPNSzoQfYB7ArOqHC6mBhlJ f6PNovIdT8oTtNPr91093LqXJ1vikAiVuVgLyPNppV4KVXj6GKM7jSI1dVJFeDr4te2v QPjB8mYuRVHBw51z8F2QSEg1Bidc19R+kEBL2cw1ulLqa+8tUAZoBcc+ysIsSqjNJQvz VCz4AQz9e0hcnAjuJK4wr9+a3OMHfBZZvOUnrx+e/69WtSVABe0OPSKhGgE1cRDCTW+T jD9qxwcrsQ799pFxVBWHR/JIInO1F8M64oxcVhzDM5Cg48fsV4wWMNMOXCuGF8jxweB5 Fx4A== X-Gm-Message-State: AO0yUKVi9hST029raw4EpqYiDWhc9kEqm6F6hFWxC6E3r/FAgRHKTH5/ vjtYvV2sNSVbiZWATJ8NF21JzzmCHN+2zQeD X-Google-Smtp-Source: AK7set+S8wEk7i+sNl4PYvEs46QsDJmezLeaz0myiWNIBTxexjRSWTdioap1mZdaaW9nPsrRMuEZIQ== X-Received: by 2002:a17:906:1b1a:b0:885:23bc:3174 with SMTP id o26-20020a1709061b1a00b0088523bc3174mr1132723ejg.70.1675724904870; Mon, 06 Feb 2023 15:08:24 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s15-20020a170906a18f00b0089d5aaf85besm2673586ejy.219.2023.02.06.15.08.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Feb 2023 15:08:24 -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 v7 16/19] grep API: plug memory leaks by freeing "header_list" Date: Tue, 7 Feb 2023 00:07:51 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1425.gac85d95d48c 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 Mon Feb 6 23:07:52 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: 13130759 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 68FCEC636D3 for ; Mon, 6 Feb 2023 23:09:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229490AbjBFXJS (ORCPT ); Mon, 6 Feb 2023 18:09:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230250AbjBFXIy (ORCPT ); Mon, 6 Feb 2023 18:08:54 -0500 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6889D32E65 for ; Mon, 6 Feb 2023 15:08:27 -0800 (PST) Received: by mail-ej1-x62b.google.com with SMTP id hx15so38654840ejc.11 for ; Mon, 06 Feb 2023 15:08:27 -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=aCb5ktRN7aM+Yj7TI/WzQB2i0lEXwNq1MPN4nQl7XPc=; b=UZoMW8ngumIqyJWjRonAEoASDfj3N+bbbZXrzfm3zjZAiRnI1i6zeo3AGVChUZ/DMj ea/WnY0teOpiAWY3UNYr8B+uw2qbJZM/9dHVi35cykHUZP5c78B6OQ3kNNnqlgAyOPgv K7R440oeC//lLrkCXs5GhiusazyrnL+zgGuGCkYwNrruMnoExLosqZhac0837DcBUSP1 bPCR4fzfPUNAfCTTKxNu7RWqkmMfGO2TofzgfCKAxWfYZL6woEfasWTgVyymMpEC9M/c 1pL/q8nxrEwe4CBi5JblhDlvcywQVqkf/okPFOh3D3DgLjC1tjRV9CmGvf2M47SOiG+c 18qA== 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=aCb5ktRN7aM+Yj7TI/WzQB2i0lEXwNq1MPN4nQl7XPc=; b=ofOAsuN1LBDnuWU4Pl4wFlduYYlku/2NqWXbkaMZMDclm16vO0c4LT7nTadsGlDJ0T O9j7jpMkaPTO63dB91xo+rWG7K/Pga6uZri1LMaMqZwCz0ogvzpMRcDK9I03+2/odlVc SHDDQhNfyR2KVdwRj1ocf8J3RNAyiR5K4l2/FW8ohVszvyZnY2iB43JAj7RFIq9Ngc+j DFqfpdQuyY2hiDUh+EJUXn+uDFCzAoPsxG/U/iOhljKzu+P4GiSqoC7gsb0WDwvJnC7O lKCbyQN8YKEsWcOWo5xXix8QIK1WQEKfUolOGgdpiljJ9JvsRj3IosfHTFeECCtWXmXl f2iA== X-Gm-Message-State: AO0yUKVTHs6TfLVqxuWNHwewb9MKhMr47EdklO7w4Zju6+E7/jOisMwJ QpsP+MGathnkVm87ELTMeTLO3Mdc8xYrpM5Q X-Google-Smtp-Source: AK7set/N+q9tX9gfzEqptNolMPpR2BM7bJnDZIwO+GJjFaIKaGO6TMBwnTvAVFnL2HqE5QnVlDu0Mw== X-Received: by 2002:a17:906:3009:b0:896:427b:148 with SMTP id 9-20020a170906300900b00896427b0148mr1180506ejz.1.1675724905702; Mon, 06 Feb 2023 15:08:25 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s15-20020a170906a18f00b0089d5aaf85besm2673586ejy.219.2023.02.06.15.08.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Feb 2023 15:08:25 -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 v7 17/19] receive-pack: release the linked "struct command *" list Date: Tue, 7 Feb 2023 00:07:52 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1425.gac85d95d48c 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 [1]. Later in [2] we started using FLEX_ALLOC_MEM() to allocate the "struct command *". 1. 575f497456e (Add first cut at "git-receive-pack", 2005-06-29) 2. eb1af2df0b1 (git-receive-pack: start parsing ref update commands, 2005-06-29) Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/receive-pack.c | 11 +++++++++++ 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, 22 insertions(+) diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index a90af303630..cd5c7a28eff 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -2032,6 +2032,16 @@ 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 +2579,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 Mon Feb 6 23:07:53 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: 13130758 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 F2070C61DA4 for ; Mon, 6 Feb 2023 23:09:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229982AbjBFXJP (ORCPT ); Mon, 6 Feb 2023 18:09:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230249AbjBFXIy (ORCPT ); Mon, 6 Feb 2023 18:08:54 -0500 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63C5A32E64 for ; Mon, 6 Feb 2023 15:08:27 -0800 (PST) Received: by mail-ej1-x634.google.com with SMTP id m2so38748649ejb.8 for ; Mon, 06 Feb 2023 15:08:27 -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=2eXl3+EDO0/r7rJ8+Sx4W8+/GhtaIl6wOPh90YwjqeA=; b=CeBNYKeAlSX0bP/fyVZj2J9GfvJCqwazwvEprIe7r95a301Bxqt/Fa74aSEZjbVCpz oraueK79+Lru/GYAzh6NROQn3XtXD9CiwKIv5y98E1d4LwLH+Ur3hshivUPtPOzvrtEj orScj8Nwb26Pu7COW75+5H5fRluqbTWUS9iG+OWC5Q1zm3SMHGofCJuzhgeEfFgdCL48 Yumo8mRNygV8VZi1vxMOnG7AxoJBEEcNXZPs8768sUzMse/Er9qB92vynNuL0uUHRkCR vFgnjB1UD5m5KrWYL21yYI8+gJUXknJQANge32ZQw7nJhy9l9x0FunA0TDGV8qmJZYOT zNNA== 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=2eXl3+EDO0/r7rJ8+Sx4W8+/GhtaIl6wOPh90YwjqeA=; b=rS4mYJKC9fach3L1TOcAh9PRULhGlugjDzFBb7nc3G6d/L0rdee1FQK4KEizblgnKq Ga3YQs/ZPuzMw67yrXd5DEM2KcVTrvuBzxWEohCzTrFzxbyCzxgPbx5ENX3yvvolyyEH pCMvq31gTvjWJwZGq8RvdnVR4oRQ3gu4noF+gS4NcwjD8KOIHj9bmzjOWf0FWYzb6bPF nfFShkNxNDYyauYvu/jZbU+hHgvI2b8wJujJ8ysFjt2SZHad6iIPzffE6EOKfAwFQV3v RVSTeaF7kQfeXaqTOUJ7N7XkYkLJkghhc37MvpnTB5e/SeLCVoYZX9XxXcv/iYaRuFLe YmXA== X-Gm-Message-State: AO0yUKW4Y53DXYc06CoHzo/DG5PZiBHLzDVoitHaojgMtKzxMaNvAer+ vH8qkCDT5Ehav/x4s+Ql/iUwILsF/8zRK910 X-Google-Smtp-Source: AK7set9gPd530hbriGWfUUDFi3hf3wjig+KoOPmUxTGejI/OFGUY0ii0NUqwl5XZcEA1uMvca7QO+g== X-Received: by 2002:a17:906:edbb:b0:887:2248:efd5 with SMTP id sa27-20020a170906edbb00b008872248efd5mr951291ejb.77.1675724906615; Mon, 06 Feb 2023 15:08:26 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s15-20020a170906a18f00b0089d5aaf85besm2673586ejy.219.2023.02.06.15.08.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Feb 2023 15:08:25 -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 v7 18/19] push: refactor refspec_append_mapped() for subsequent leak-fix Date: Tue, 7 Feb 2023 00:07:53 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1425.gac85d95d48c 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 Mon Feb 6 23:07:54 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: 13130760 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 71245C05027 for ; Mon, 6 Feb 2023 23:09:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230223AbjBFXJb (ORCPT ); Mon, 6 Feb 2023 18:09:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230257AbjBFXIy (ORCPT ); Mon, 6 Feb 2023 18:08:54 -0500 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B53032515 for ; Mon, 6 Feb 2023 15:08:28 -0800 (PST) Received: by mail-ej1-x631.google.com with SMTP id mc11so38697254ejb.10 for ; Mon, 06 Feb 2023 15:08:28 -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=qbKpJivg5mwqDYN753Piyui4ktEEBmy0/cA1S1WuRWI=; b=VZz9KAg4jL2cWiK6m7AplVkmT1eIjG/t7ONDqWCghTh6Ff0ByTEdVv2x9wRa6mhtqg T2iaHdmTSvX+K+Wj4Wmy9O7VQj8yW6uuqkjndgCZ7i7HGTo+Gl/mI8ILFqRz7id52pQj Fx3iFWO5UzdY3BbAPs2Jb6Htwwp96DA04ZJ4HHYqbLHIbxtdCRxKQLXWucSCx8sLZbz6 0t3tM/5eUOIG5o/7he5DwIv+kQVn9wm5EY7ARp4i5XVEDu3DwBvY42JSsDkx5mv6LQAO jbs0q4RzW39PfbkL5aLwRWwyMZEc+9It5jaWlfRBzKOyy03D01Ex8ZH2hUnZFPZddZTV XfPw== 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=qbKpJivg5mwqDYN753Piyui4ktEEBmy0/cA1S1WuRWI=; b=He4I1kwjj4i0lhcpJyvzoAFUEks0Edlt0IVwma2T6Ar4imfybwof9pNwvv3ukY+QqI K0bKSwGWZ9NKqLG3Pv2d90nnN3Gj+svgIGENzklcnzdSyjWh5n5YO1qvbDqbQmQGTfUm 9LQ6m090YJp0zvNJPzWkLmoeEUaZAxDpKeE+8ziJ4MGD3G4WR+pW0Efr3uogbautntE8 JBCXMdfU1fOP6x0F4ZflQ+N5Z8DgbB1p8bx9Cg6GPxp6rhFo7H4mYdZpfGvAI2kOjUkA NrgCrBybbB7HNDzeJfX2AnYnt4CXy3MefJUNxhLj3p16dvDvGJ0X18IHH9iScKFX2cNF vpNg== X-Gm-Message-State: AO0yUKWA1nIqOG8rkcaJe1eKXXCyREsLosf4jUdxtR2LkxU3cQtKOLnP dvSfH042anLtxwc43e+GJINExX0K1RcSvNKL X-Google-Smtp-Source: AK7set/eUQOj0ptQ+yzeUKK0gZcx82trn9+O1wrDPj8zq2Q1DdTqRqwuIKg6qyTdXfb2ImAifs478g== X-Received: by 2002:a17:906:3a8f:b0:88f:a236:69e6 with SMTP id y15-20020a1709063a8f00b0088fa23669e6mr1131881ejd.7.1675724907558; Mon, 06 Feb 2023 15:08:27 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id s15-20020a170906a18f00b0089d5aaf85besm2673586ejy.219.2023.02.06.15.08.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Feb 2023 15:08:26 -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 v7 19/19] push: free_refs() the "local_refs" in set_refspecs() Date: Tue, 7 Feb 2023 00:07:54 +0100 Message-Id: X-Mailer: git-send-email 2.39.1.1425.gac85d95d48c 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