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

[PATCH] index-pack, unpack-objects: restore missing ->init_fn

From
JHJensen Huang <hmz007@gmail.com>
Date
Mar 18, 2025, 11:16 UTC
Message-ID
<20250318111616.113941-1-hmz007@gmail.com>

Commit 0578f1e66a ("global: adapt callers to use generic hash context helpers") accidentally removed `->init_fn`, which is required for OpenSSL 3+ SHA1.

This fixes the following error on fetch:
  fatal: fetch-pack: invalid index-pack output
Signed-off-by: Jensen Huang <hmz007@gmail.com>
---
 builtin/index-pack.c     | 1 +
 builtin/unpack-objects.c | 1 +
 2 files changed, 2 insertions(+)
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 52cc97d52c..50573ba049 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -1286,6 +1286,7 @@ static void parse_pack_objects(unsigned char *hash)
 
 	/* Check pack integrity */
 	flush();
+	the_hash_algo->init_fn(&tmp_ctx);
 	git_hash_clone(&tmp_ctx, &input_ctx);
 	git_hash_final(hash, &tmp_ctx);
 	if (!hasheq(fill(the_hash_algo->rawsz), hash, the_repository->hash_algo))
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index 8383bcf404..c5a6dca856 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
@@ -668,6 +668,7 @@ int cmd_unpack_objects(int argc,
 	the_hash_algo->init_fn(&ctx);
 	unpack_all();
 	git_hash_update(&ctx, buffer, offset);
+	the_hash_algo->init_fn(&tmp_ctx);
 	git_hash_clone(&tmp_ctx, &ctx);
 	git_hash_final_oid(&oid, &tmp_ctx);
 	if (strict) {
-- 
2.49.0-1
Next: Patrick Steinhardt
Message 1 of 5 in “index-pack, unpack-objects: restore missing ->init_fn”
  1. index-pack, unpack-objects: restore missing ->init_fnJensen Huang, Mar 18, 2025
  2. Patrick SteinhardtMar 19, 2025
  3. gtXfined H.Mar 19, 2025
  4. Patrick SteinhardtMar 19, 2025
  5. Junio C HamanoMar 21, 2025

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.