tar: make error reporting more robust and use correct errno

Apply upstream pull request 2101.
This commit is contained in:
Ed Maste 2024-03-31 10:37:38 -04:00
parent 9eff58c6d5
commit d68c68693e

View file

@ -372,8 +372,9 @@ read_archive(struct bsdtar *bsdtar, char mode, struct archive *writer)
if (r != ARCHIVE_OK) {
if (!bsdtar->verbose)
safe_fprintf(stderr, "%s", archive_entry_pathname(entry));
fprintf(stderr, ": %s: ", archive_error_string(a));
fprintf(stderr, "%s", strerror(errno));
safe_fprintf(stderr, ": %s: %s",
archive_error_string(a),
strerror(archive_errno(a)));
if (!bsdtar->verbose)
fprintf(stderr, "\n");
bsdtar->return_value = 1;