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

[PATCH] archive: Store checksum correctly

From
MTMatt Turner <mattst88@gmail.com>
Date
Jul 23, 2019, 02:57 UTC
Message-ID
<20190723025736.23036-1-mattst88@gmail.com>

tar2sqfs (part of https://github.com/topics/tar2sqfs) rejects tarballs made with git archive with the message

    invalid tar header checksum!

tar2sqfs recomputes the tarball's checksum to verify it. Its checksum implementation agrees with GNU tar, which contains a comment that states

    Fill in the checksum field.  It's formatted differently from the
    other fields: it has [6] digits, a null, then a space ...

Correcting this allows tar2sqfs to correctly process the tarballs made by git archive.

Signed-off-by: Matt Turner <mattst88@gmail.com>
---
 archive-tar.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/archive-tar.c b/archive-tar.c
index 3e53aac1e6..f9a157bfd1 100644
--- a/archive-tar.c
+++ b/archive-tar.c
@@ -215,7 +215,9 @@ static void prepare_header(struct archiver_args *args,
 	memcpy(header->magic, "ustar", 6);
 	memcpy(header->version, "00", 2);
 
-	xsnprintf(header->chksum, sizeof(header->chksum), "%07o", ustar_header_chksum(header));
+	xsnprintf(header->chksum, sizeof(header->chksum), "%06o", ustar_header_chksum(header));
+	header->chksum[6] = '\0';
+	header->chksum[7] = ' ';
 }
 
 static void write_extended_header(struct archiver_args *args,
-- 
2.22.0.dirty
Next: Junio C Hamano
Message 1 of 8 in “archive: Store checksum correctly”
  1. archive: Store checksum correctlyMatt Turner, Jul 23, 2019
  2. Junio C HamanoJul 23, 2019
  3. Jeff KingJul 23, 2019
  4. René ScharfeJul 23, 2019
  5. René ScharfeJul 23, 2019
  6. David OberhollenzerJul 23, 2019
  7. Junio C HamanoJul 23, 2019
  8. Jonathan NiederJul 24, 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.