mirror of
https://github.com/git/git
synced 2024-08-25 10:45:59 +00:00
![Jeff King](/assets/img/avatar_default.png)
As we parse the author-script file, we check for missing or duplicate lines for GIT_AUTHOR_NAME, etc. But after reading the whole file, our final error conditional checks "date_i" twice and "name_i" not at all. This not only leads to us failing to abort, but we may do an out-of-bounds read on the string_list array. The bug goes back to442c36bd08
(am: improve author-script error reporting, 2018-10-31), though the code was soon after moved to this spot bybcd33ec25f
(add read_author_script() to libgit, 2018-10-31). It was presumably just a typo in442c36bd08
. We'll add test coverage for all the error cases here, though only the GIT_AUTHOR_NAME ones fail (even in a vanilla build they segfault consistently, but certainly with SANITIZE=address). Reported-by: Michael V. Scovetta <michael.scovetta@gmail.com> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
60 lines
1.2 KiB
Bash
Executable file
60 lines
1.2 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
test_description='rebase behavior when on-disk files are broken'
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success 'set up conflicting branches' '
|
|
test_commit base file &&
|
|
git checkout -b branch1 &&
|
|
test_commit one file &&
|
|
git checkout -b branch2 HEAD^ &&
|
|
test_commit two file
|
|
'
|
|
|
|
create_conflict () {
|
|
test_when_finished "git rebase --abort" &&
|
|
git checkout -B tmp branch2 &&
|
|
test_must_fail git rebase branch1
|
|
}
|
|
|
|
check_resolve_fails () {
|
|
echo resolved >file &&
|
|
git add file &&
|
|
test_must_fail git rebase --continue
|
|
}
|
|
|
|
for item in NAME EMAIL DATE
|
|
do
|
|
test_expect_success "detect missing GIT_AUTHOR_$item" '
|
|
create_conflict &&
|
|
|
|
grep -v $item .git/rebase-merge/author-script >tmp &&
|
|
mv tmp .git/rebase-merge/author-script &&
|
|
|
|
check_resolve_fails
|
|
'
|
|
done
|
|
|
|
for item in NAME EMAIL DATE
|
|
do
|
|
test_expect_success "detect duplicate GIT_AUTHOR_$item" '
|
|
create_conflict &&
|
|
|
|
grep -i $item .git/rebase-merge/author-script >tmp &&
|
|
cat tmp >>.git/rebase-merge/author-script &&
|
|
|
|
check_resolve_fails
|
|
'
|
|
done
|
|
|
|
test_expect_success 'unknown key in author-script' '
|
|
create_conflict &&
|
|
|
|
echo "GIT_AUTHOR_BOGUS=${SQ}whatever${SQ}" \
|
|
>>.git/rebase-merge/author-script &&
|
|
|
|
check_resolve_fails
|
|
'
|
|
|
|
test_done
|