git: a2ce5a2dc95f - stable/13 - tar: make error reporting more robust and use correct errno

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Sun, 07 Apr 2024 16:59:01 UTC
The branch stable/13 has been updated by emaste:

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

commit a2ce5a2dc95f7ce0de644abd963bd77edfb86fc3
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2024-03-31 14:37:38 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2024-04-07 16:58:50 +0000

    tar: make error reporting more robust and use correct errno
    
    Apply upstream pull request 2101.
    
    (cherry picked from commit d68c68693e110353f70b5c04f8de416cf5766eca)
    (cherry picked from commit bade279b8106e9d4166ef2430b4bdbcf17be9953)
---
 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;