Thread (7 messages) flat view 7 messages, 3 authors, 2019-08-17
STALE2594d

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

From: René Scharfe <hidden>
Date: 2019-08-17 16:24:28
Subsystem: the rest · Maintainer: Linus Torvalds

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 <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help