decoder: fix heap-buffer-overflow in Intra_PCM decoding#3950
Open
bwendling wants to merge 1 commit into
Open
Conversation
Fix a heap-buffer-overflow vulnerability in `WelsActualDecodeMbCavlcISlice`, `WelsActualDecodeMbCavlcPSlice`, and `WelsActualDecodeMbCavlcBSlice` when handling `MB_TYPE_INTRA_PCM` macroblocks. The decoder previously performed an unconditional read of 384 bytes from the bitstream buffer without verifying the remaining buffer size or the `uiChromaFormatIdc` value. On truncated or malformed bitstreams, this resulted in reading past `pBs->pEndBuf`. Additionally, the code incorrectly attempted to process chroma data for monochrome (4:0:0) streams. Changes: - Added a boundary check against `pBs->pEndBuf` before reading PCM data. - Calculated required data size (384 bytes for 4:2:0, 256 bytes for 4:0:0) based on `uiChromaFormatIdc`. - Conditioned chroma data copying and bitstream pointer advancement on the chroma format. - Ensured `pBs->pCurBuf` is advanced by the correct byte count. This fix prevents out-of-bounds access when `pBs->pCurBuf - iIndex + size` exceeds the allocated bitstream buffer. Co-authored-by: CodeMender <codemender-patching@google.com> Fixes: https://issues.oss-fuzz.com/issues/479908882
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.
Fix a heap-buffer-overflow vulnerability in
WelsActualDecodeMbCavlcISlice,WelsActualDecodeMbCavlcPSlice, andWelsActualDecodeMbCavlcBSlicewhen handlingMB_TYPE_INTRA_PCMmacroblocks.The decoder previously performed an unconditional read of 384 bytes from the bitstream buffer without verifying the remaining buffer size or the
uiChromaFormatIdcvalue. On truncated or malformed bitstreams, this resulted in reading pastpBs->pEndBuf. Additionally, the code incorrectly attempted to process chroma data for monochrome (4:0:0) streams.Changes:
pBs->pEndBufbefore reading PCM data.uiChromaFormatIdc.pBs->pCurBufis advanced by the correct byte count.This fix prevents out-of-bounds access when
pBs->pCurBuf - iIndex + sizeexceeds the allocated bitstream buffer.Fixes: https://issues.oss-fuzz.com/issues/479908882