diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2022-03-09 17:01:38 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-03-09 19:25:27 +0100 |
commit | 4f33a6345f2bd6e47253d1dbefd01874d895ab2e (patch) | |
tree | 4d0d23fbf380aabd8f2af4e835ba174f41b3b6fb /t/t6020-bundle-misc.sh | |
parent | MyFirstObjectWalk: update recommended usage (diff) | |
download | git-4f33a6345f2bd6e47253d1dbefd01874d895ab2e.tar.xz git-4f33a6345f2bd6e47253d1dbefd01874d895ab2e.zip |
list-objects: handle NULL function pointers
If a caller to traverse_commit_list() specifies the options for the
--objects flag but does not specify a show_object function pointer, the
result is a segfault. This is currently visible by running 'git bundle
create --objects HEAD'.
We could fix this problem by supplying a no-op callback in
builtin/bundle.c, but that only solves the problem for one builtin,
leaving this segfault open for other callers.
Replace all callers of the show_commit and show_object function pointers
in list-objects.c to call helper functions show_commit() and
show_object() which check that the given context has non-NULL functions
before passing the necessary data. One extra benefit is that it reduces
duplication due to passing ctx->show_data to every caller.
Test that this segfault no longer occurs for 'git bundle'.
Co-authored-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to '')
-rwxr-xr-x | t/t6020-bundle-misc.sh | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/t/t6020-bundle-misc.sh b/t/t6020-bundle-misc.sh index b13e8a52a9..df5ff561fa 100755 --- a/t/t6020-bundle-misc.sh +++ b/t/t6020-bundle-misc.sh @@ -475,4 +475,16 @@ test_expect_success 'clone from bundle' ' test_cmp expect actual ' +test_expect_success 'unfiltered bundle with --objects' ' + git bundle create all-objects.bdl \ + --all --objects && + git bundle create all.bdl \ + --all && + + # Compare the headers of these files. + sed -n -e "/^$/q" -e "p" all.bdl >expect && + sed -n -e "/^$/q" -e "p" all-objects.bdl >actual && + test_cmp expect actual +' + test_done |