Re: [PATCH v2 3/6] Make sure fsck_commit_buffer() does not run out of the buffer
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Sep 11, 2014, 11:59 UTC
- Message-ID
- <alpine.DEB.1.00.1409111352130.990@s15462909.onlinehome-server.info>
- In-Reply-To
- <xmqqlhprgylt.fsf@gitster.dls.corp.google.com>
Hi Junio,
On Wed, 10 Sep 2014, Junio C Hamano wrote:
Show 25 quoted lines
> Johannes Schindelin <johannes.schindelin@gmx.de> writes:
>
> > diff --git a/fsck.c b/fsck.c
> > index dd77628..9dd7d12 100644
> > --- a/fsck.c
> > +++ b/fsck.c
> > @@ -237,6 +237,26 @@ static int fsck_tree(struct tree *item, int strict, fsck_error error_func)
> > return retval;
> > }
> >
> > +static int require_end_of_header(const void *data, unsigned long size,
> > + struct object *obj, fsck_error error_func)
> > +{
> > + const char *buffer = (const char *)data;
> > + int i;
> > +
> > + for (i = 0; i < size; i++) {
> > + switch (buffer[i]) {
> > + case '\0':
> > + return error_func(obj, FSCK_ERROR,
> > + "invalid message: NUL at offset %d", i);
>
> Isn't this "invalid header"? After all we haven't escaped this loop
> and haven't seen the message part of the commit object (and it is
> the same if you are going to later reuse this for tag objects).My reasoning for keeping it saying "message" was that a message consists of a header and a body. I will change it to "unterminated header" instead, also in the error message when no NUL was found.
Ciao, Dscho