Repository navigation
Decoding robustness: track numbers, audio size, bounded reading, FFV1 - #558
Merged
JeromeMartinez merged 4 commits intoNov 23, 2026
Merged
Conversation
…header Missing or extra audio blocks in the compressed file (e.g. blocks lost during a remux) gave a shorter or longer WAV/AIFF file without error, --check included when the file was encoded without --hash. The data size declared in the header of the file (data chunk, ds64 for RF64, SSND chunk) is now compared to the size of the decoded audio data at the end of the track.
The zlib content of the reversibility data and of the attachments was inflated into a buffer of the size declared in the file, without limit: a crafted size could abort with an uncaught std::bad_alloc or allocate gigabytes, a size above 4 GiB was truncated in 32-bit builds, and a content not inflated correctly was used partially (e.g. as the header of a restored file). The declared size is now refused above the maximal deflate ratio or above the addressable size, memory errors are caught, and the content is empty when it is not readable. The attachments use the same reader. Also: - new slots of the file sizes are zeroed (frames without file size), - no null pointer is given to memcpy()/memset()/memcmp() with a size of 0 (empty buffers, empty file names).
The track number of a block was read as a 1-byte value, so the tracks after the 127th could not be decoded, and it was used as the position of the track entry, so a file with track numbers not in the order of the track entries (e.g. remuxed) had its blocks given to the wrong tracks (e.g. video decoded as FLAC). The track number of a block is now read as an EBML variable-size integer and mapped to the track entry declaring this TrackNumber. The RawCookedTrack elements still describe the track entries by position.
- The slices are allocated with the first frame of each slot, when the frame size is known and the slice grid is checked against it, instead of with the configuration record (an unchecked grid could allocate gigabytes or overflow the count of slices). - Memory errors end the frame with an error instead of terminating. - The slice boundaries are computed with 64-bit products (overflow with big frames or many slices). - A slice with an invalid header is not decoded (its position is unknown), and a slice without decoding states (error in its keyframe) is not decoded instead of using a null pointer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes found during the work on the Photoshop layers, independent from it.
--checkincluded when the file was encoded without--hash. The data size declared in the header (data chunk, ds64 for RF64, SSND chunk) is now compared to the size of the decoded audio data.std::bad_alloc, gigabytes allocated, truncation in 32-bit builds) and a content not inflated correctly was used partially. The size is now bounded by the maximal deflate ratio, memory errors are caught, and unreadable content is empty. New file size slots are zeroed, and no null pointer is given tomemcpy()/memset()/memcmp()with a size of 0.