diff options
author | Junio C Hamano <gitster@pobox.com> | 2018-11-21 16:57:52 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-11-21 16:57:52 +0300 |
commit | d75c41b2ae0a4d5dc40af5e7b84afed791bf77c3 (patch) | |
tree | 2673c4dbac06ee9aa57a16be52bee3bf36e601fa /t | |
parent | 0e57d28a3a867cf2a1cef9e429150709b6f89b91 (diff) | |
parent | 18ad13e5b2ee18c3f57bf41add3efa95980e72c1 (diff) |
Merge branch 'jk/detect-truncated-zlib-input' into maint
A regression in Git 2.12 era made "git fsck" fall into an infinite
loop while processing truncated loose objects.
* jk/detect-truncated-zlib-input:
cat-file: handle streaming failures consistently
check_stream_sha1(): handle input underflow
t1450: check large blob in trailing-garbage test
Diffstat (limited to 't')
-rwxr-xr-x | t/t1450-fsck.sh | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh index 0f2dd26f74..b5677d26a4 100755 --- a/t/t1450-fsck.sh +++ b/t/t1450-fsck.sh @@ -673,16 +673,35 @@ test_expect_success 'fsck detects trailing loose garbage (commit)' ' test_i18ngrep "garbage.*$commit" out ' -test_expect_success 'fsck detects trailing loose garbage (blob)' ' +test_expect_success 'fsck detects trailing loose garbage (large blob)' ' blob=$(echo trailing | git hash-object -w --stdin) && file=$(sha1_file $blob) && test_when_finished "remove_object $blob" && chmod +w "$file" && echo garbage >>"$file" && - test_must_fail git fsck 2>out && + test_must_fail git -c core.bigfilethreshold=5 fsck 2>out && test_i18ngrep "garbage.*$blob" out ' +test_expect_success 'fsck detects truncated loose object' ' + # make it big enough that we know we will truncate in the data + # portion, not the header + test-tool genrandom truncate 4096 >file && + blob=$(git hash-object -w file) && + file=$(sha1_file $blob) && + test_when_finished "remove_object $blob" && + test_copy_bytes 1024 <"$file" >tmp && + rm "$file" && + mv -f tmp "$file" && + + # check both regular and streaming code paths + test_must_fail git fsck 2>out && + test_i18ngrep corrupt.*$blob out && + + test_must_fail git -c core.bigfilethreshold=128 fsck 2>out && + test_i18ngrep corrupt.*$blob out +' + # for each of type, we have one version which is referenced by another object # (and so while unreachable, not dangling), and another variant which really is # dangling. |