Merge branch 'jk/detect-truncated-zlib-input' into maint
authorJunio C Hamano <gitster@pobox.com>
Wed, 21 Nov 2018 13:57:52 +0000 (22:57 +0900)
committerJunio C Hamano <gitster@pobox.com>
Wed, 21 Nov 2018 13:57:52 +0000 (22:57 +0900)
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

1  2 
sha1-file.c
diff --combined sha1-file.c
index 2edf4564f6c12f33c59a101470cd2964774fcc34,6d6c3af6598c33623d10a930a39afaf9de74db1a..03b86aec710c3afffcd989bd357d28241a0271a7
@@@ -1317,7 -1317,7 +1317,7 @@@ int oid_object_info_extended(struct rep
                         * TODO Pass a repository struct through fetch_object,
                         * such that arbitrary repositories work.
                         */
 -                      fetch_object(repository_format_partial_clone, real->hash);
 +                      fetch_objects(repository_format_partial_clone, real, 1);
                        already_retried = 1;
                        continue;
                }
@@@ -2191,7 -2191,8 +2191,8 @@@ static int check_stream_sha1(git_zstrea
         * see the comment in unpack_sha1_rest for details.
         */
        while (total_read <= size &&
-              (status == Z_OK || status == Z_BUF_ERROR)) {
+              (status == Z_OK ||
+               (status == Z_BUF_ERROR && !stream->avail_out))) {
                stream->next_out = buf;
                stream->avail_out = sizeof(buf);
                if (size - total_read < stream->avail_out)