]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
read_data_into_fd: Print correct error code
authorTobias Stoeckmann <tobias@stoeckmann.org>
Sun, 7 Jun 2026 14:44:36 +0000 (16:44 +0200)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Sun, 7 Jun 2026 15:14:33 +0000 (17:14 +0200)
If lseek fails to seek to correct position, e.g. because the descriptor
is in append mode, do not use errno because it's not set.

In such a case, fall back to ARCHIVE_ERRNO_MISC.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
libarchive/archive_read_data_into_fd.c

index 8fd5e12442bc43b9c821fa99f527e0925df943ae..8d56d70428417c9fe283e3557092758d5ca431ea 100644 (file)
@@ -56,7 +56,9 @@ pad_to(struct archive *a, int fd, int can_lseek,
                actual_offset = lseek(fd,
                    target_offset - actual_offset, SEEK_CUR);
                if (actual_offset != target_offset) {
-                       archive_set_error(a, errno, "Seek error");
+                       archive_set_error(a,
+                           actual_offset == -1 ? errno : ARCHIVE_ERRNO_MISC,
+                           "Seek error");
                        return (ARCHIVE_FATAL);
                }
                return (ARCHIVE_OK);