Re: [PATCH 3/3] commit-graph.c: handle corrupt/missing trees

2019-09-09 Thread Junio C Hamano
Jeff King writes: >> Answer. There is a single hit inside fsck.c that wants to report >> an error without killing ourselves in fsck_commit_buffer(). I >> however doubt its use of get_commit_tree() is correct in the >> first place. The function is about validating the commit obje

Re: [PATCH 3/3] commit-graph.c: handle corrupt/missing trees

2019-09-06 Thread Jeff King
On Fri, Sep 06, 2019 at 12:51:56PM -0400, Derrick Stolee wrote: > > This one in theory benefits lots of other callsites, too, since it means > > we'll actually return NULL instead of nonsense like "8". But grepping > > around for calls to this function, I found literally zero of them > > actually

Re: [PATCH 3/3] commit-graph.c: handle corrupt/missing trees

2019-09-06 Thread Jeff King
On Fri, Sep 06, 2019 at 11:42:14AM -0400, Taylor Blau wrote: > > > struct object_id *get_commit_tree_oid(const struct commit *commit) > > > { > > > - return &get_commit_tree(commit)->object.oid; > > > + struct tree *tree = get_commit_tree(commit); > > > + return tree ? &tree->object.oid : NULL;

Re: [PATCH 3/3] commit-graph.c: handle corrupt/missing trees

2019-09-06 Thread Jeff King
On Fri, Sep 06, 2019 at 10:11:09AM -0700, Junio C Hamano wrote: > > Is there even a single caller that is prepared to react to NULL? > > > > Answer. There is a single hit inside fsck.c that wants to report > > an error without killing ourselves in fsck_commit_buffer(). I > > however d

Re: [PATCH 3/3] commit-graph.c: handle corrupt/missing trees

2019-09-06 Thread Jeff King
On Fri, Sep 06, 2019 at 09:57:29AM -0700, Junio C Hamano wrote: > Jeff King writes: > > > This is sort-of attributable to my 834876630b (get_commit_tree(): return > > NULL for broken tree, 2019-04-09). Before then it was a BUG(). However, > > that state was relatively short-lived. Before 7b8a21d

Re: [PATCH 3/3] commit-graph.c: handle corrupt/missing trees

2019-09-06 Thread Junio C Hamano
Junio C Hamano writes: > ... > Is there even a single caller that is prepared to react to NULL? > > Answer. There is a single hit inside fsck.c that wants to report > an error without killing ourselves in fsck_commit_buffer(). I > however doubt its use of get_commit_tree() is correct

Re: [PATCH 3/3] commit-graph.c: handle corrupt/missing trees

2019-09-06 Thread Junio C Hamano
Jeff King writes: > This is sort-of attributable to my 834876630b (get_commit_tree(): return > NULL for broken tree, 2019-04-09). Before then it was a BUG(). However, > that state was relatively short-lived. Before 7b8a21dba1 (commit-graph: > lazy-load trees for commits, 2018-04-06), we'd have si

Re: [PATCH 3/3] commit-graph.c: handle corrupt/missing trees

2019-09-06 Thread Derrick Stolee
On 9/6/2019 2:19 AM, Jeff King wrote: > On Thu, Sep 05, 2019 at 06:04:57PM -0400, Taylor Blau wrote: > >> @@ -846,7 +847,11 @@ static void write_graph_chunk_data(struct hashfile *f, >> int hash_len, >> if (parse_commit_no_graph(*list)) >> die(_("unable to parse c

Re: [PATCH 3/3] commit-graph.c: handle corrupt/missing trees

2019-09-06 Thread Taylor Blau
On Fri, Sep 06, 2019 at 02:19:20AM -0400, Jeff King wrote: > On Thu, Sep 05, 2019 at 06:04:57PM -0400, Taylor Blau wrote: > > > @@ -846,7 +847,11 @@ static void write_graph_chunk_data(struct hashfile *f, > > int hash_len, > > if (parse_commit_no_graph(*list)) > > di

Re: [PATCH 3/3] commit-graph.c: handle corrupt/missing trees

2019-09-05 Thread Jeff King
On Thu, Sep 05, 2019 at 06:04:57PM -0400, Taylor Blau wrote: > @@ -846,7 +847,11 @@ static void write_graph_chunk_data(struct hashfile *f, > int hash_len, > if (parse_commit_no_graph(*list)) > die(_("unable to parse commit %s"), >

[PATCH 3/3] commit-graph.c: handle corrupt/missing trees

2019-09-05 Thread Taylor Blau
Apply similar treatment as in the previous commit to handle an unchecked call to 'get_commit_tree_oid()'. Previously, a NULL return value from this function would be immediately dereferenced with '->hash', and then cause a segfault. Before dereferencing to access the 'hash' member, check the retur