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:
2 files changed
+22
-2
No files matched your search
@@ -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
@@ -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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user