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

[PATCH 4/4] archive-tar: turn length miscalculation warning into BUG

From
René Scharfe <l.s.r@web.de>
Date
Aug 17, 2019, 16:24 UTC
Message-ID
<f5ad09f8-9da5-9567-afe0-f1379bd9192b@web.de>
In-Reply-To
<c77a0081-93ab-7b97-e322-9616f6e7f86c@web.de>

Now that we're confident our pax extended header calculation is correct, turn the criticality of the assertion up to the maximum, from warning right up to BUG. Simplify the test, as the stderr comparison step would not be reached in case the BUG message is triggered.

Signed-off-by: René Scharfe <l.s.r@web.de>
---
 archive-tar.c                   | 6 +++---
 t/t5004-archive-corner-cases.sh | 3 +--
 2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/archive-tar.c b/archive-tar.c
index 9d09edd547..e16d3f756d 100644
--- a/archive-tar.c
+++ b/archive-tar.c
@@ -158,9 +158,9 @@ static void strbuf_append_ext_header(struct strbuf *sb, const char *keyword,
 	strbuf_addch(sb, '\n');

 	if (len != sb->len - orig_len)
-		warning("pax extended header length miscalculated as %"PRIuMAX
-			", should be %"PRIuMAX,
-			(uintmax_t)len, (uintmax_t)(sb->len - orig_len));
+		BUG("pax extended header length miscalculated as %"PRIuMAX
+		    ", should be %"PRIuMAX,
+		    (uintmax_t)len, (uintmax_t)(sb->len - orig_len));
 }

 /*
diff --git a/t/t5004-archive-corner-cases.sh b/t/t5004-archive-corner-cases.sh
index 4966a74b4d..3e7b23cb32 100755
--- a/t/t5004-archive-corner-cases.sh
+++ b/t/t5004-archive-corner-cases.sh
@@ -220,8 +220,7 @@ build_tree() {
 test_expect_success 'tar archive with long paths' '
 	blob=$(echo foo | git hash-object -w --stdin) &&
 	tree=$(build_tree $blob | git mktree) &&
-	git archive -o long_paths.tar $tree 2>stderr &&
-	test_must_be_empty stderr
+	git archive -o long_paths.tar $tree
 '

 test_done
--
2.23.0
Previous: René ScharfeNext: brian m. carlson
Message 6 of 7 in “fix pax extended header length calculation”
  1. 0/4 fix pax extended header length calculationRené Scharfe, Aug 17, 2019
  2. 1/4 archive-tar: report wrong pax extended header lengthRené Scharfe, Aug 17, 2019
  3. 2/4 archive-tar: fix pax extended header length calculationRené Scharfe, Aug 17, 2019
  4. Eric SunshineAug 17, 2019
  5. 3/4 archive-tar: use size_t in strbuf_append_ext_header()René Scharfe, Aug 17, 2019
  6. 4/4 archive-tar: turn length miscalculation warning into BUGRené Scharfe, Aug 17, 2019
  7. brian m. carlsonAug 17, 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.