]> git.ipfire.org Git - thirdparty/git.git/commitdiff
config API users: test for *_get_value_multi() segfaults
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Tue, 28 Mar 2023 14:04:26 +0000 (16:04 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 28 Mar 2023 14:37:53 +0000 (07:37 -0700)
As we'll discuss in the subsequent commit these tests all
show *_get_value_multi() API users unable to handle there being a
value-less key in the config, which is represented with a "NULL" for
that entry in the "string" member of the returned "struct
string_list", causing a segfault.

These added tests exhaustively test for that issue, as we'll see in a
subsequent commit we'll need to change all of the API users
of *_get_value_multi(). These cases were discovered by triggering each
one individually, and then adding these tests.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t4202-log.sh
t/t5310-pack-bitmaps.sh
t/t7004-tag.sh
t/t7413-submodule-is-active.sh
t/t7900-maintenance.sh

index 2ce2b41174d501f998b9e9edb4faa8ba969629f6..e4f02d8208b4d274935a37962f1bf6d80b858ada 100755 (executable)
@@ -835,6 +835,17 @@ test_expect_success 'log.decorate configuration' '
 
 '
 
+test_expect_failure 'parse log.excludeDecoration with no value' '
+       cp .git/config .git/config.orig &&
+       test_when_finished mv .git/config.orig .git/config &&
+
+       cat >>.git/config <<-\EOF &&
+       [log]
+               excludeDecoration
+       EOF
+       git log --decorate=short
+'
+
 test_expect_success 'decorate-refs with glob' '
        cat >expect.decorate <<-\EOF &&
        Merge-tag-reach
index 6d693eef82f74a72ad4f29c399e297427c892d12..2e65c8139c4f3507cc1d65bc5b357ca756b0d29c 100755 (executable)
@@ -404,6 +404,22 @@ test_bitmap_cases () {
                )
        '
 
+       test_expect_failure 'pack.preferBitmapTips' '
+               git init repo &&
+               test_when_finished "rm -rf repo" &&
+               (
+                       cd repo &&
+                       git config pack.writeBitmapLookupTable '"$writeLookupTable"' &&
+                       test_commit_bulk --message="%s" 103 &&
+
+                       cat >>.git/config <<-\EOF &&
+                       [pack]
+                               preferBitmapTips
+                       EOF
+                       git repack -adb
+               )
+       '
+
        test_expect_success 'complains about multiple pack bitmaps' '
                rm -fr repo &&
                git init repo &&
index 9aa1660651b8a96397ce2a83cb3d107c8b7d43dc..f343551a7d445c097ae4d49373081e83cc2d2e57 100755 (executable)
@@ -1843,6 +1843,18 @@ test_expect_success 'invalid sort parameter in configuratoin' '
        test_must_fail git tag -l "foo*"
 '
 
+test_expect_failure 'version sort handles empty value for versionsort.{prereleaseSuffix,suffix}' '
+       cp .git/config .git/config.orig &&
+       test_when_finished mv .git/config.orig .git/config &&
+
+       cat >>.git/config <<-\EOF &&
+       [versionsort]
+               prereleaseSuffix
+               suffix
+       EOF
+       git tag -l --sort=version:refname
+'
+
 test_expect_success 'version sort with prerelease reordering' '
        test_config versionsort.prereleaseSuffix -rc &&
        git tag foo1.6-rc1 &&
index 7cdc26376490e80274c4f699ddd0b00c25e4d9cd..bfe27e507322144914421584ef0372a988b79e9d 100755 (executable)
@@ -51,6 +51,18 @@ test_expect_success 'is-active works with submodule.<name>.active config' '
        test-tool -C super submodule is-active sub1
 '
 
+test_expect_failure 'is-active handles submodule.active config missing a value' '
+       cp super/.git/config super/.git/config.orig &&
+       test_when_finished mv super/.git/config.orig super/.git/config &&
+
+       cat >>super/.git/config <<-\EOF &&
+       [submodule]
+               active
+       EOF
+
+       test-tool -C super submodule is-active sub1
+'
+
 test_expect_success 'is-active works with basic submodule.active config' '
        test_when_finished "git -C super config submodule.sub1.URL ../sub" &&
        test_when_finished "git -C super config --unset-all submodule.active" &&
index 823331e44a03b2f62e9f1577a84f08863150388d..d82eac6a471eacef7d8038ce1c7b014f87d95bb5 100755 (executable)
@@ -524,6 +524,29 @@ test_expect_success 'register and unregister' '
        git maintenance unregister --config-file ./other --force
 '
 
+test_expect_failure 'register with no value for maintenance.repo' '
+       cp .git/config .git/config.orig &&
+       test_when_finished mv .git/config.orig .git/config &&
+
+       cat >>.git/config <<-\EOF &&
+       [maintenance]
+               repo
+       EOF
+       git maintenance register
+'
+
+test_expect_failure 'unregister with no value for maintenance.repo' '
+       cp .git/config .git/config.orig &&
+       test_when_finished mv .git/config.orig .git/config &&
+
+       cat >>.git/config <<-\EOF &&
+       [maintenance]
+               repo
+       EOF
+       git maintenance unregister &&
+       git maintenance unregister --force
+'
+
 test_expect_success !MINGW 'register and unregister with regex metacharacters' '
        META="a+b*c" &&
        git init "$META" &&