]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Fix the test failure
authorTim Kientzle <kientzle@acm.org>
Sat, 4 Jul 2026 04:52:27 +0000 (21:52 -0700)
committerTim Kientzle <kientzle@acm.org>
Sat, 4 Jul 2026 04:52:27 +0000 (21:52 -0700)
This was originally developed without the Zip fix from #3230.
Since that's been merged, we need to adjust the expectations here
a bit.

tar/test/test_option_stdout_size_exceeds_declared.c

index 6d427b5f3884c298818a0fb325f798326c0640ce..6c9242f12fdec4d1d1de0a158fe4227865163eae 100644 (file)
  * "CCCCCCCCCCDDDDDDDDDD..." for _deflate), and "second" is a normal
  * 11-byte "hello world" file, extracted right after "first" fails to
  * confirm the mis-declared entry doesn't disrupt the rest of the
- * archive. This test is deliberately independent of the ZIP reader
- * itself enforcing this boundary: archive_read_data_into_fd() truncates
- * output at exactly the declared 10 bytes on its own, so stdout ends up
- * with "first"'s 10-byte prefix immediately followed by "second".
+ * archive.
+ *
+ * The ZIP reader itself also rejects "first" outright (a separate,
+ * format-level fix -- see test_read_format_zip_size_exceeds_declared),
+ * so archive_read_data_block() never hands this backstop any bytes for
+ * "first" to (partially) pass through: stdout ends up with none of
+ * "first"'s data at all, followed directly by "second".  That's still
+ * "never more than declared" -- just fewer bytes than the boundary
+ * allows, since the format reader was already more conservative here.
  */
 static void
-verify(const char *refname, const char *first10)
+verify(const char *refname)
 {
-       char expected[32];
-
        extract_reference_file(refname);
        failure("bsdtar -xO must report an error for the mis-declared entry");
        assert(systemf("%s -xOf %s >test.out 2>test.err", testprog, refname)
            != 0);
 
-       strcpy(expected, first10);
-       strcat(expected, "hello world");
-       assertFileContents(expected, (int)strlen(expected), "test.out");
+       assertFileContents("hello world", 11, "test.out");
        assertNonEmptyFile("test.err");
 }
 
 DEFINE_TEST(test_option_stdout_size_exceeds_declared)
 {
-       verify("test_option_stdout_size_exceeds_declared_stored.zip",
-           "AAAAAAAAAA");
-       verify("test_option_stdout_size_exceeds_declared_deflate.zip",
-           "CCCCCCCCCC");
+       verify("test_option_stdout_size_exceeds_declared_stored.zip");
+       verify("test_option_stdout_size_exceeds_declared_deflate.zip");
 }