]> git.ipfire.org Git - thirdparty/libarchive.git/commit
Do not skip past EOF while reading (#2584)
authorTobias Stoeckmann <stoeckmann@users.noreply.github.com>
Tue, 15 Apr 2025 04:02:17 +0000 (06:02 +0200)
committerGitHub <noreply@github.com>
Tue, 15 Apr 2025 04:02:17 +0000 (21:02 -0700)
commitdcbf1e0ededa95849f098d154a25876ed5754bcf
treef36060b17948282198e7e5805d1a62155e30c5bc
parentf96497248e3b4e70e3ba985a4f2ff213e274a180
Do not skip past EOF while reading (#2584)

Make sure to not skip past end of file for better error messages. One
such example is now visible with rar testsuite. You can see the
difference already by an actually not useless use of cat:

```
$ cat .../test_read_format_rar_ppmd_use_after_free.rar | bsdtar -t
bsdtar: Archive entry has empty or unreadable filename ... skipping.
bsdtar: Archive entry has empty or unreadable filename ... skipping.
bsdtar: Truncated input file (needed 119 bytes, only 0 available)
bsdtar: Error exit delayed from previous errors.
```

compared to

```
$ bsdtar -tf .../test_read_format_rar_ppmd_use_after_free.rar
bsdtar: Archive entry has empty or unreadable filename ... skipping.
bsdtar: Archive entry has empty or unreadable filename ... skipping.
bsdtar: Error exit delayed from previous errors.
```

Since the former cannot lseek, the error is a different one
(ARCHIVE_FATAL vs ARCHIVE_EOF). The piped version states explicitly that
truncation occurred, while the latter states EOF because the skip past
the end of file was successful.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
libarchive/archive_read_open_fd.c
libarchive/archive_read_open_file.c
libarchive/archive_read_open_filename.c
libarchive/test/test_read_format_rar.c