Re: [PATCH] unpack_sha1_header(): detect malformed object header
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 26, 2016, 17:39 UTC
- Message-ID
- <xmqqbmzatv9u.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <20160926173540.j4rxcks3pmdcyvtd@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 14 quoted lines
>> diff --git a/streaming.c b/streaming.c >> index 811fcc2..884a8f1 100644 >> --- a/streaming.c >> +++ b/streaming.c >> @@ -347,7 +347,8 @@ static open_method_decl(loose) >> return -1; >> } >> >> - parse_sha1_header(st->u.loose.hdr, &st->size); >> + if (parse_sha1_header(st->u.loose.hdr, &st->size) < 0) >> + return -1; > > Do you have to git_inflate_end() and munmap() here, as the error path > above does (this was missing from my patch, too)?
Ah, definitely. We'd need to be consistent; otherwise we'd be either leaking resources (or existing one double-freeing).