git: bade279b8106 - stable/14 - tar: make error reporting more robust and use correct errno

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Wed, 03 Apr 2024 13:07:12 UTC
The branch stable/14 has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=bade279b8106e9d4166ef2430b4bdbcf17be9953

commit bade279b8106e9d4166ef2430b4bdbcf17be9953
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2024-03-31 14:37:38 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2024-04-03 13:06:41 +0000

    tar: make error reporting more robust and use correct errno
    
    Apply upstream pull request 2101.
    
    (cherry picked from commit d68c68693e110353f70b5c04f8de416cf5766eca)
---
 contrib/libarchive/tar/read.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/contrib/libarchive/tar/read.c b/contrib/libarchive/tar/read.c
index 2a907518d7cb..94616f279e65 100644
--- a/contrib/libarchive/tar/read.c
+++ b/contrib/libarchive/tar/read.c
@@ -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;