]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
tar: make error reporting more robust and use correct errno (#2101)
authorEd Maste <emaste@freebsd.org>
Fri, 29 Mar 2024 22:02:06 +0000 (18:02 -0400)
committerGitHub <noreply@github.com>
Fri, 29 Mar 2024 22:02:06 +0000 (15:02 -0700)
As discussed in #1609.

tar/read.c

index af3d3f423daff024791465bb9976a9b9a74b91ad..a7f14a07bb35602256b732cf3de96892e4280523 100644 (file)
@@ -371,8 +371,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;