]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
bsdcpio should exit with an error code if an entry can't be extracted (#2371)
authorMostyn Bramley-Moore <mostyn@antipode.se>
Mon, 7 Oct 2024 15:51:17 +0000 (17:51 +0200)
committerGitHub <noreply@github.com>
Mon, 7 Oct 2024 15:51:17 +0000 (08:51 -0700)
For example if --insecure is not specified, and one of the security
checks fails.

cpio/cpio.c
cpio/test/test_extract_cpio_absolute_paths.c
cpio/test/test_option_d.c

index d4d9ac88555fd3967713775e7d8bb78780e04102..4180cbe5b3b0508e42d9db0a2654d3dc5da68766 100644 (file)
@@ -1032,6 +1032,7 @@ mode_in(struct cpio *cpio)
                        fprintf(stderr, "%s: %s\n",
                            archive_entry_pathname(entry),
                            archive_error_string(ext));
+                       cpio->return_value = 1;
                } else if (!archive_entry_size_is_set(entry)
                    || archive_entry_size(entry) > 0) {
                        r = extract_data(a, ext);
index 3c2a6a63dd64d7b377bf88317d4de516914e3711..66fc56641bd0667788af22a7a7af8e4b92474f10 100644 (file)
@@ -42,7 +42,7 @@ DEFINE_TEST(test_extract_cpio_absolute_paths)
 
        // We should refuse to create the absolute path without --insecure.
        r = systemf("%s -i < archive.cpio 2> stderr2.txt", testprog);
-       //assert(r != 0); // Should this command fail?
+       assert(r != 0);
        assertFileNotExists(temp_absolute_file_name);
        UNLINK(temp_absolute_file_name); // Cleanup just in case.
 
index b96430e4f37a32775740904c50fbb8e0ba591864..8c785e44c0d76273836084348bd7aa905b350ed5 100644 (file)
@@ -44,7 +44,7 @@ DEFINE_TEST(test_option_d)
        assertMakeDir("without-d", 0755);
        assertChdir("without-d");
        r = systemf("%s -i < ../archive.cpio >out 2>err", testprog);
-       assertEqualInt(r, 0);
+       assert(r != 0);
        assertEmptyFile("out");
        /* And the file should not be restored. */
        assertFileNotExists("dir/file");