Bounds-check macroblock/motion/audio indices to fix four OOB accesses (#73)#74
Open
nakata-app wants to merge 1 commit into
Open
Bounds-check macroblock/motion/audio indices to fix four OOB accesses (#73)#74nakata-app wants to merge 1 commit into
nakata-app wants to merge 1 commit into
Conversation
- decode_macroblock: reject negative mb_row/mb_col (OOB read at :3532, OOB write at :3514/:3519) - process_macroblock: bound half-pel interpolation reads to the plane (:3372) - audio_decode_header: reject bitrate_index == -1 (global read at :4076) No behavior change on valid streams: a 75-frame MPEG-1 clip decodes to byte-identical output before and after. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
This fixes the four memory-safety bugs reported in #73, all reachable from crafted MPEG-1 input via
plm_decode_video()/plm_decode_audio(). Three targeted bounds checks, no behavior change on valid streams.1.
plm_video_decode_macroblock, negativemb_row/mb_col(Bug A read at :3532, Bug D write at :3514/:3519)The existing guard checks only the upper bound. When
macroblock_addressis driven negative,mb_row/mb_colbecome negative, both>=checks pass, and the deriveddiindex goes negative. In the non-intra path that is an OOB read (d[di]); in the intra pathPLM_BLOCK_SETdoes an OOB write (heap corruption, 16 bytes before the frame plane). Adding the lower-bound check closes both.2.
plm_video_process_macroblock, half-pel interpolation past plane end (Bug B read at :3372)The old
max_addressguard reserves room for theblock_size x block_sizeblock but not for the half-pel neighbors the interpolation cases read (s[si + dw + 1]at the bottom-right). The new guard checks the actual maximum index touched: the block span for the write side (di), plus the interpolation neighbor (+ dw + 1, gated onodd_h/odd_v) for the read side (si). This rejects only reads that would leave the plane; valid motion compensation stays in-bounds.3.
plm_audio_decode_header,bitrate_index == -1(Bug C, global read at :4076)bitrate_index = read(4) - 1yields-1for the free-format nibble0. The guard only rejects> 13, so-1slips through toPLM_AUDIO_BIT_RATE[-1]. Reject the negative case too.Verification
e2dba4d8a37b5192on both builds).