diff options
author | Junio C Hamano <gitster@pobox.com> | 2018-11-13 13:37:17 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-11-13 13:37:17 (GMT) |
commit | 879a8d4bf2412303ec940d69165b0937c11a2851 (patch) | |
tree | f610f532a4da757bc9b5480cce825e2e937bbb37 /t | |
parent | fd7761a1cd1d8ab5cb311b6e7f91e56496e95b84 (diff) | |
parent | 18ad13e5b2ee18c3f57bf41add3efa95980e72c1 (diff) | |
download | git-879a8d4bf2412303ec940d69165b0937c11a2851.zip git-879a8d4bf2412303ec940d69165b0937c11a2851.tar.gz git-879a8d4bf2412303ec940d69165b0937c11a2851.tar.bz2 |
Merge branch 'jk/detect-truncated-zlib-input'
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 0f2dd26..b5677d2 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. |