]> git.ipfire.org Git - thirdparty/libarchive.git/commit
rar: return ARCHIVE_FAILED (not ARCHIVE_FATAL) for per-entry data errors
authorTim Kientzle <kientzle@acm.org>
Sun, 3 May 2026 22:21:09 +0000 (15:21 -0700)
committerTim Kientzle <kientzle@acm.org>
Sun, 3 May 2026 22:21:09 +0000 (15:21 -0700)
commit4f148608e35f02a9fd86d51ec2a5d0d765faba59
tree1d9463d5e877da49aeb6055ddc7fb572f04eef48
parentfeeafefbe5e6c6223d7b8bba0db4127dff677a97
rar: return ARCHIVE_FAILED (not ARCHIVE_FATAL) for per-entry data errors

ARCHIVE_FATAL means the entire archive is unreadable and no further
operations are valid.  ARCHIVE_FAILED means the current entry cannot
be processed but iteration over subsequent entries may still succeed.

The RAR4 decompressor was returning ARCHIVE_FATAL from a large number
of data-parsing failures (invalid Huffman prefix, invalid PPMd sequence,
bad CRC, invalid symbol, etc.) that are per-entry errors.  Because each
entry's compressed data region can be skipped using the packed_size
recorded in its file header, a decompressor error does not prevent
reading the next entry's header.

Change all such per-entry errors in the data-reading path
(read_data_stored, read_data_compressed, parse_codes, create_code,
add_value, make_table_recurse, expand, copy_from_lzss_window,
copy_from_lzss_window_to_unp) to return ARCHIVE_FAILED.  OOM errors
and true I/O failures (rar_br_preparation truncated-data) remain
ARCHIVE_FATAL.
libarchive/archive_read_support_format_rar.c