Skip to content

Commit 1c7e239

Browse files
avargitster
authored andcommitted
config API users: test for *_get_value_multi() segfaults
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f7b2ff9 commit 1c7e239

File tree

5 files changed

+74
-0
lines changed

5 files changed

+74
-0
lines changed

t/t4202-log.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,17 @@ test_expect_success 'log.decorate configuration' '
835835
836836
'
837837

838+
test_expect_failure 'parse log.excludeDecoration with no value' '
839+
cp .git/config .git/config.orig &&
840+
test_when_finished mv .git/config.orig .git/config &&
841+
842+
cat >>.git/config <<-\EOF &&
843+
[log]
844+
excludeDecoration
845+
EOF
846+
git log --decorate=short
847+
'
848+
838849
test_expect_success 'decorate-refs with glob' '
839850
cat >expect.decorate <<-\EOF &&
840851
Merge-tag-reach

t/t5310-pack-bitmaps.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,22 @@ test_bitmap_cases () {
404404
)
405405
'
406406

407+
test_expect_failure 'pack.preferBitmapTips' '
408+
git init repo &&
409+
test_when_finished "rm -rf repo" &&
410+
(
411+
cd repo &&
412+
git config pack.writeBitmapLookupTable '"$writeLookupTable"' &&
413+
test_commit_bulk --message="%s" 103 &&
414+
415+
cat >>.git/config <<-\EOF &&
416+
[pack]
417+
preferBitmapTips
418+
EOF
419+
git repack -adb
420+
)
421+
'
422+
407423
test_expect_success 'complains about multiple pack bitmaps' '
408424
rm -fr repo &&
409425
git init repo &&

t/t7004-tag.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1843,6 +1843,18 @@ test_expect_success 'invalid sort parameter in configuratoin' '
18431843
test_must_fail git tag -l "foo*"
18441844
'
18451845

1846+
test_expect_failure 'version sort handles empty value for versionsort.{prereleaseSuffix,suffix}' '
1847+
cp .git/config .git/config.orig &&
1848+
test_when_finished mv .git/config.orig .git/config &&
1849+
1850+
cat >>.git/config <<-\EOF &&
1851+
[versionsort]
1852+
prereleaseSuffix
1853+
suffix
1854+
EOF
1855+
git tag -l --sort=version:refname
1856+
'
1857+
18461858
test_expect_success 'version sort with prerelease reordering' '
18471859
test_config versionsort.prereleaseSuffix -rc &&
18481860
git tag foo1.6-rc1 &&

t/t7413-submodule-is-active.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ test_expect_success 'is-active works with submodule.<name>.active config' '
5151
test-tool -C super submodule is-active sub1
5252
'
5353

54+
test_expect_failure 'is-active handles submodule.active config missing a value' '
55+
cp super/.git/config super/.git/config.orig &&
56+
test_when_finished mv super/.git/config.orig super/.git/config &&
57+
58+
cat >>super/.git/config <<-\EOF &&
59+
[submodule]
60+
active
61+
EOF
62+
63+
test-tool -C super submodule is-active sub1
64+
'
65+
5466
test_expect_success 'is-active works with basic submodule.active config' '
5567
test_when_finished "git -C super config submodule.sub1.URL ../sub" &&
5668
test_when_finished "git -C super config --unset-all submodule.active" &&

t/t7900-maintenance.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,29 @@ test_expect_success 'register and unregister' '
524524
git maintenance unregister --config-file ./other --force
525525
'
526526

527+
test_expect_failure 'register with no value for maintenance.repo' '
528+
cp .git/config .git/config.orig &&
529+
test_when_finished mv .git/config.orig .git/config &&
530+
531+
cat >>.git/config <<-\EOF &&
532+
[maintenance]
533+
repo
534+
EOF
535+
git maintenance register
536+
'
537+
538+
test_expect_failure 'unregister with no value for maintenance.repo' '
539+
cp .git/config .git/config.orig &&
540+
test_when_finished mv .git/config.orig .git/config &&
541+
542+
cat >>.git/config <<-\EOF &&
543+
[maintenance]
544+
repo
545+
EOF
546+
git maintenance unregister &&
547+
git maintenance unregister --force
548+
'
549+
527550
test_expect_success !MINGW 'register and unregister with regex metacharacters' '
528551
META="a+b*c" &&
529552
git init "$META" &&

0 commit comments

Comments
 (0)