git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/2] parse_commit_buffer: don't parse invalid commits

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 14, 2008, 07:23 UTC
Message-ID
<7vk5mclvk3.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<12002478702664-git-send-email-mkoegler@auto.tuwien.ac.at>
Martin Koegler <mkoegler@auto.tuwien.ac.at> writes:
Show 5 quoted lines
> +	if (!parse_commit_date(bufptr, tail, &item->date))
> +		return error("bogus commit date in object %s", sha1_to_hex(item->object.sha1));
>  
>  	if (track_object_refs) {
>  		unsigned i = 0;
I suspect this might be an undesirable regression.

If somebody managed to create a commit with a bogus "author" line and wanted to clean up the history, your previous one at least gave something usable back, even though it had to come up with a bogus date. It gave the rest of the data back without barfing. And it was easy to see which "resurrected" commit had a missing author date (bogus ones always gave 0 timestamp).

This round you made it to error out, and callers that check the return value of parse_commit() would stop traversing the history, even if the commit in question has perfectly valid "parent " lines, thinking "ah, this commit object is faulty". It actively interferes with attempts to resurrect data from history that contains a faulty commit.

Your previous version was much better with respect to this issue. It was about being more careful not to read outside the commit object buffer, while still allowing the data from a history that has an unfortunate commit with broken author line to be resurrected more easily.

I do not think the checks done by fsck and parse_commit should share the same strictness. They serve different purposes.

Previous: Martin KoeglerNext: Martin Koegler
Message 5 of 7 in “parse_commit_buffer: don't parse invalid commits”
  1. 1/2 parse_commit_buffer: don't parse invalid commitsMartin Koegler, Jan 13, 2008
  2. 2/2 git-fsck: remove commit test already done by parse_commit_bufferMartin Koegler, Jan 13, 2008
  3. Junio C HamanoJan 13, 2008
  4. Martin KoeglerJan 14, 2008
  5. Junio C HamanoJan 14, 2008
  6. Martin KoeglerJan 14, 2008
  7. Junio C HamanoJan 14, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.