How Unrar Handles Invalid Volume Sequence Numbers
When extracting split multi-volume RAR sets, the unrar
utility relies on internal header flags and volume counters to assemble
spanned data in the correct order. If an archive presents an invalid or
unexpected volume sequence number, unrar interrupts the
continuous decompression stream to prevent data corruption. This article
explains how unrar validates volume headers, how it behaves
in interactive versus non-interactive modes when sequence errors occur,
and the impact of out-of-order volumes on the extraction of individual
files.
Volume Header Verification
Multi-volume RAR sets include specialized header blocks—such as the Archive Header and Main Header—that define volume properties. Within these headers, specific flags denote whether an archive is part of a multi-volume set, whether it is the first volume, and which sequential index it occupies.
During extraction, unrar maintains an internal state
machine that tracks the expected next volume number. As each new volume
is loaded, the utility parses the volume header before decompressing any
payload. If the header’s volume number does not match the expected
integer (for example, reading volume 3 immediately after volume 1),
unrar flags the archive as an out-of-sequence or missing
volume rather than parsing corrupted data blocks.
Interactive Prompting vs. Batch Execution
How unrar reacts to an invalid sequence number depends
largely on the execution environment and command-line switches:
- Interactive Mode: If
unraris run in an interactive terminal without automation flags, encountering an invalid sequence number triggers a prompt. The utility asks the user to manually locate or insert the correct archive volume (e.g., displayingCannot find volume [name]or prompting for a new file path). If the user provides a file with the valid matching sequence number, extraction resumes seamlessly. - Non-Interactive Mode: In batch environments, or
when switches such as
-y(assume yes) or-inul(disable messages) are active,unrarcannot prompt for user input. In this scenario, it aborts the process, reports a non-zero exit code indicating a missing or corrupt volume, and halts decompression.
Impact on Spanned vs. Self-Contained Files
The compression dictionary in RAR files can span across multiple volumes. An invalid sequence number affects individual files differently depending on their location in the archive:
- Files Spanning Volumes: If a single file begins in a valid volume but continues across a missing or out-of-sequence boundary, extraction fails completely. Because the sliding compression dictionary requires continuous byte streams, any jump or missing link invalidates the decompressor state, resulting in a CRC mismatch or an unexpected end-of-archive error.
- Self-Contained Files: Files that start and finish
entirely within the volumes processed prior to the sequence error are
extracted normally and remain intact on disk. However, unless forced
with specific switches such as
-kb(keep broken extracted files),unrardefaults to deleting partially extracted files that were in the middle of being reconstructed when the sequence error occurred.