Re: [PATCH] unpack_sha1_header(): detect malformed object header

2016-09-26 Thread Jeff King
On Mon, Sep 26, 2016 at 10:33:57AM -0700, Junio C Hamano wrote: > -- >8 -- > From: Junio C Hamano > Date: Mon, 26 Sep 2016 09:23:41 -0700 > Subject: [PATCH 1/2] streaming: make sure to notice corrupt object > > The streaming read interface from a loose object called > parse_sha1_header() but dis

Re: [PATCH] unpack_sha1_header(): detect malformed object header

2016-09-26 Thread Junio C Hamano
Jeff King writes: >> 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

Re: [PATCH] unpack_sha1_header(): detect malformed object header

2016-09-26 Thread Jeff King
On Mon, Sep 26, 2016 at 10:34:32AM -0700, Junio C Hamano wrote: > And the second one, that no longer checks SP in unpacker, looks like > this. This looks good from a cursory read (but I am about to go to sleep, so might be a bit less careful than usual :) ). -Peff

Re: [PATCH] unpack_sha1_header(): detect malformed object header

2016-09-26 Thread Junio C Hamano
And the second one, that no longer checks SP in unpacker, looks like this. -- >8 -- Subject: [PATCH] unpack_sha1_header(): detect malformed object header When opening a loose object file, we often do this sequence: - prepare a short buffer for the object header (on stack) - c

Re: [PATCH] unpack_sha1_header(): detect malformed object header

2016-09-26 Thread Junio C Hamano
Junio C Hamano writes: > Good that your attempt to signature-changing change caught it. I'll > take a further look. So here are two patch series. The first one makes sure all callers of parse_sha1_header() check the returned status. -- >8 -- From: Junio C Hamano Date: Mon, 26 Sep 2016 09:23:

Re: [PATCH] unpack_sha1_header(): detect malformed object header

2016-09-26 Thread Junio C Hamano
Jeff King writes: > This part I don't understand, though. We clearly need to look for the > NUL. But why do we need to look for the space? The loop in > parse_sha1_header() can easily detect this as it looks for the end of > the type name (and if it hits the end-of-string, can bail as in your > o

Re: [PATCH] unpack_sha1_header(): detect malformed object header

2016-09-26 Thread Jeff King
On Sun, Sep 25, 2016 at 09:29:04PM -0700, Junio C Hamano wrote: > To correct this, do these three things: > > - rename unpack_sha1_header() to unpack_sha1_short_header() and >have unpack_sha1_header_to_strbuf() keep calling that as its >helper function. This will detect and report zlib

[PATCH] unpack_sha1_header(): detect malformed object header

2016-09-25 Thread Junio C Hamano
When opening a loose object file, we often do this sequence: - prepare a short buffer for the object header (on stack) - call unpack_sha1_header() and have early part of the object data inflated, enough to fill the buffer - parse that data in the short buffer, assuming that the first part