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

[RFC PATCH 1/1] commit-graph.c: die on un-parseable commits

From
Taylor Blau <me@ttaylorr.com>
Date
Sep 4, 2019, 02:22 UTC
Message-ID
<34e4ec793cb0d321d16b88777cd2db64ed7b772e.1567563244.git.me@ttaylorr.com>
In-Reply-To
<cover.1567563244.git.me@ttaylorr.com>

When we write a commit graph chunk, we process a given list of 'struct commit *'s and parse out the parent(s) and tree OID in order to write out its information.

We do this by calling 'parse_commit_no_graph', and then checking the result of 'get_commit_tree_oid' to write the tree OID. This process assumes that 'parse_commit_no_graph' parses the commit successfully. When this isn't the case, 'get_commit_tree_oid(*list)' may return NULL, in which case trying to '->hash' it causes a SIGSEGV.

Instead, teach 'write_graph_chunk_data' to stop when a commit isn't able to be parsed, at the peril of failing to write a commit-graph.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
---
 commit-graph.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/commit-graph.c b/commit-graph.c
index f2888c203b..6aa6998ecd 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -843,7 +843,9 @@ static void write_graph_chunk_data(struct hashfile *f, int hash_len,
 		uint32_t packedDate[2];
 		display_progress(ctx->progress, ++ctx->progress_cnt);
 
-		parse_commit_no_graph(*list);
+		if (parse_commit_no_graph(*list))
+			die(_("unable to parse commit %s"),
+				oid_to_hex(&(*list)->object.oid));
 		hashwrite(f, get_commit_tree_oid(*list)->hash, hash_len);
 
 		parent = (*list)->parents;
-- 
2.22.0
Previous: Taylor BlauNext: Jeff King
Message 2 of 20 in “commit-graph.c: handle corrupt commit trees”
  1. 0/1 commit-graph.c: handle corrupt commit treesTaylor Blau, Sep 4, 2019
  2. 1/1 commit-graph.c: die on un-parseable commitsTaylor Blau, Sep 4, 2019
  3. Jeff KingSep 4, 2019
  4. Taylor BlauSep 4, 2019
  5. Jeff KingSep 5, 2019
  6. Derrick StoleeSep 6, 2019
  7. Jeff KingSep 6, 2019
  8. Derrick StoleeSep 6, 2019
  9. Derrick StoleeSep 6, 2019
  10. Junio C HamanoSep 5, 2019
  11. Jeff KingSep 6, 2019
  12. Jeff KingSep 6, 2019
  13. Junio C HamanoSep 6, 2019
  14. Jeff KingSep 6, 2019
  15. Junio C HamanoSep 9, 2019
  16. Jeff KingSep 9, 2019
  17. Garima SinghSep 4, 2019
  18. Taylor BlauSep 4, 2019
  19. Jeff KingSep 5, 2019
  20. Derrick StoleeSep 6, 2019

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.