git: d68c68693e11 - main - tar: make error reporting more robust and use correct errno

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Sun, 31 Mar 2024 14:40:29 UTC
The branch main has been updated by emaste:

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

commit d68c68693e110353f70b5c04f8de416cf5766eca
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2024-03-31 14:37:38 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2024-03-31 14:39:53 +0000

    tar: make error reporting more robust and use correct errno
    
    Apply upstream pull request 2101.
---
 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;