git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] archive: Store checksum correctly
@ 2019-07-23  2:57 Matt Turner
  2019-07-23 16:49 ` Junio C Hamano
  2019-07-24  1:04 ` Jonathan Nieder
  0 siblings, 2 replies; 8+ messages in thread
From: Matt Turner @ 2019-07-23  2:57 UTC (permalink / raw)
  To: git; +Cc: David Oberhollenzer, Matt Turner

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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-07-24  1:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-23  2:57 [PATCH] archive: Store checksum correctly Matt Turner
2019-07-23 16:49 ` Junio C Hamano
2019-07-23 19:31   ` Jeff King
2019-07-23 19:38   ` René Scharfe
2019-07-23 20:08     ` René Scharfe
2019-07-23 21:34       ` David Oberhollenzer
2019-07-23 21:21     ` Junio C Hamano
2019-07-24  1:04 ` Jonathan Nieder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).