Repository navigation
libavc: add upper bound check for SEI payload size - #166
Merged
Merged
Conversation
In ih264d_parse_sei_message(), each 0xFF byte read from the bitstream adds 255 bytes to ui4_payload_size while consuming only 1 byte from the buffer. For a large run of 0xFF bytes, passing (ui4_payload_size << 3) to CHECK_BITS_SUFFICIENT causes (u4_ofst + bits_to_read) to overflow UWORD32. Return ERROR_EOB_GETBITS_T from the 0xFF loop as soon as ui4_payload_size exceeds the number of bytes left in the bitstream. This bounds ui4_payload_size so that (ui4_payload_size << 3) can no longer overflow. Bug: 514726621 Flag: EXEMPT BUGFIX Test: atest MctsMediaV2TestCases Test: atest MctsMediaDecoderTestCases Test: atest MctsMediaCodecTestCases Test: atest VtsHalMediaC2V1_0TargetVideoDecTest Change-Id: I42d25e758ecf4e28f272a1c368f07c051a2b8353 (cherry picked from commit efc40c25f6d1ca30b00b459dec383ec88f20eb8f)
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.
In ih264d_parse_sei_message(), each 0xFF byte read from the bitstream adds 255 bytes to ui4_payload_size while consuming only 1 byte from the buffer. For a large run of 0xFF bytes, passing (ui4_payload_size << 3) to CHECK_BITS_SUFFICIENT causes (u4_ofst + bits_to_read) to overflow UWORD32.
Return ERROR_EOB_GETBITS_T from the 0xFF loop as soon as ui4_payload_size exceeds the number of bytes left in the bitstream. This bounds ui4_payload_size so that (ui4_payload_size << 3) can no longer overflow.
Bug: 514726621
Flag: EXEMPT BUGFIX
Test: atest MctsMediaV2TestCases
Test: atest MctsMediaDecoderTestCases
Test: atest MctsMediaCodecTestCases
Test: atest VtsHalMediaC2V1_0TargetVideoDecTest
Change-Id: I42d25e758ecf4e28f272a1c368f07c051a2b8353 (cherry picked from commit efc40c25f6d1ca30b00b459dec383ec88f20eb8f)