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

Re: [PATCH] fsck: check results of lookup_blob() and lookup_tree() for NULL

From
René Scharfe <l.s.r@web.de>
Date
Oct 5, 2017, 19:41 UTC
Message-ID
<1cf044ae-ae3f-4d44-3aac-b5cc6584de1e@web.de>
In-Reply-To
<xmqqh8vfftp7.fsf@gitster.mtv.corp.google.com>
Am 04.10.2017 um 06:00 schrieb Junio C Hamano:
Show 30 quoted lines
> René Scharfe <l.s.r@web.de> writes:
>> lookup_blob() and lookup_tree() can return NULL if they find an object
>> of an unexpected type.  Error out of fsck_walk_tree() in that case, like
>> we do when encountering a bad file mode.  An error message is already
>> shown by object_as_type(), which gets called by the lookup functions.
> 
> The result from options->walk() is checked, and among the callbacks
> that are assigned to the .walk field:
> 
>   - mark_object() in builtin/fsck.c gives its own error message to diagnose broken link
>     and returns 1;
> 
>   - mark_used() in builtin/fsck.c silently returns 1;
> 
>   - mark_link() in builtin/index-pack.c does the same; and
> 
>   - check_object() in builtin/unpack-objects.c does the same,
> 
> when they see a NULL object.
> 
> This patch may avoid the "unexpected behaviour" coming from
> expecting that &((struct tree *)NULL)->object == NULL the current
> code does, but it also changes the behaviour.  The loop used to
> diagnose a fishy entry in the tree we are walking, and kept checking
> the remaining entries in the tree.  You now immediately return, not
> seeing if the later entries in the tree are good and losing objects
> that are referenced by these entries as dangling.
> 
> I am not sure if this is a good change.  I suspect that the "bad
> mode" handling should be made less severe instead.

Makes sense. Replacement patch coming up. I'll pass on the mode handling change, though (at least for now).

René
Previous: Junio C HamanoNext: René Scharfe
Message 10 of 13 in “tag: avoid NULL pointer arithmetic”
  1. tag: avoid NULL pointer arithmeticRené Scharfe, Oct 1, 2017
  2. Junio C HamanoOct 2, 2017
  3. Jeff KingOct 2, 2017
  4. René ScharfeOct 2, 2017
  5. Jeff KingOct 2, 2017
  6. SZEDER GáborOct 3, 2017
  7. René ScharfeOct 3, 2017
  8. fsck: check results of lookup_blob() and lookup_tree() for NULLRené Scharfe, Oct 3, 2017
  9. Junio C HamanoOct 4, 2017
  10. René ScharfeOct 5, 2017
  11. fsck: handle NULL return of lookup_blob() and lookup_tree()René Scharfe, Oct 5, 2017
  12. Junio C HamanoOct 6, 2017
  13. René ScharfeOct 6, 2017

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.