Re: [PATCH v2 3/6] Make sure fsck_commit_buffer() does not run out of the buffer
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 11, 2014, 16:49 UTC
- Message-ID
- <xmqqegvif6gx.fsf@gitster.dls.corp.google.com>
- In-Reply-To
- <alpine.DEB.1.00.1409111352130.990@s15462909.onlinehome-server.info>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 13 quoted lines
>> > + 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.Because end users think of a "message" in the context of discussing either a commit or a tag as what they give as the value to the "-m" option, the object payload consists of a header and a body the latter of which *is* the message to them. Choosing a word that is not "message" is a good way to avoid potential confusion here.