Merge pull request #3345 from PeiweiHu/peiwei_fix

Fix bsdtar’s `@archive` handling by freeing input readers after open failures and applying passphrases to the correct reader object.
This commit is contained in:
Tim Kientzle authored and GitHub committed 2026-08-03 22:16:19 -07:00
commit ca8b5cdfe3
2 files changed
+22 -2

No files matched your search

+19
View File
@@ -21,4 +21,23 @@ DEFINE_TEST(test_option_passphrase)
assertTextFileContents("contents of file2.\n", "file2");
assertEmptyFile("test.out");
assertEmptyFile("test.err");
/* The passphrase must also be applied to archives read via @archive. */
failure("--passphrase option is broken with @archive");
assertEqualInt(0, systemf(
"%s --passphrase pass1 -cf append.tar @%s "
">append-create.out 2>append-create.err",
testprog, reffile));
assertEmptyFile("append-create.out");
assertEmptyFile("append-create.err");
assertMakeDir("append", 0755);
assertEqualInt(0, systemf(
"%s -xf append.tar -C append "
">append-extract.out 2>append-extract.err",
testprog));
assertTextFileContents("contents of file1.\n", "append/file1");
assertTextFileContents("contents of file2.\n", "append/file2");
assertEmptyFile("append-extract.out");
assertEmptyFile("append-extract.err");
}
+3 -2
View File
@@ -673,15 +673,16 @@ append_archive_filename(struct bsdtar *bsdtar, struct archive *a,
set_reader_options(bsdtar, ina);
archive_read_set_options(ina, "mtree:checkfs");
if (bsdtar->passphrase != NULL)
rc = archive_read_add_passphrase(a, bsdtar->passphrase);
rc = archive_read_add_passphrase(ina, bsdtar->passphrase);
else
rc = archive_read_set_passphrase_callback(ina, bsdtar,
&passphrase_callback);
if (rc != ARCHIVE_OK)
lafe_errc(1, 0, "%s", archive_error_string(a));
lafe_errc(1, 0, "%s", archive_error_string(ina));
if (archive_read_open_filename(ina, filename,
bsdtar->bytes_per_block)) {
lafe_warnc(0, "%s", archive_error_string(ina));
archive_read_free(ina);
bsdtar->return_value = 1;
return (0);
}