Re: [PATCH 04/10] unpack_loose_header(): fix infinite loop on broken zlib input
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 26, 2025, 12:56 UTC
- Message-ID
- <xmqq34g0hnkr.fsf@gitster.g>
- In-Reply-To
- <20250225062958.GD1293961@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 12 quoted lines
> diff --git a/object-file.c b/object-file.c > index 8c9295413b..5b2446bfc1 100644 > --- a/object-file.c > +++ b/object-file.c > @@ -1396,7 +1396,7 @@ enum unpack_loose_header_result unpack_loose_header(git_zstream *stream, > strbuf_add(header, buffer, stream->next_out - (unsigned char *)buffer); > if (memchr(buffer, '\0', stream->next_out - (unsigned char *)buffer)) > return 0; > - } while (status != Z_STREAM_END); > + } while (status == Z_OK); > return ULHR_BAD; > }
Ah, fond memories. I do recall we had very similar bugs whose correct solution was "instead of stopping with Z_something, just write your loop to keep ging while you get Z_OK" every time we encountered them.