Fix out-of-bounds array read in File_Aac_Main #2117
Merged
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.
As mentioned in #2105 (comment), this is one of the issues found with Visual Studio Code Analysis and also Cppcheck.
Visual Studio:
![Screenshot 2024-09-30 175112](https://private-user-images.githubusercontent.com/77721854/372050844-29f65b13-950f-49d8-8cc9-bec15921682d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1NTU4MzUsIm5iZiI6MTczOTU1NTUzNSwicGF0aCI6Ii83NzcyMTg1NC8zNzIwNTA4NDQtMjlmNjViMTMtOTUwZi00OWQ4LThjYzktYmVjMTU5MjE2ODJkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE0VDE3NTIxNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTM5YjA3MmUwYWY0M2FkNmY0Y2FhOWI0MzQ1ZjUwZDJkN2YzZDA1NDBiNmUyNGQ4ZGE3YjU4N2JjM2Q0MmRiYjAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.KP0CtEwHDtuhrLBgINEjyWVczqKYP2jqhzCaLc5mO3g)
Cppcheck:
MediaInfoLib/Source/MediaInfo/Audio/File_Aac_Main.cpp
Lines 498 to 501 in 00d9658
The issue is that
Aac_OutputChannelPosition_Size
is 43 andAac_ChannelMode
has 43 elements. Since an array starts with0
, the max we can access inAac_ChannelMode
is 42. So we change>Aac_OutputChannelPosition_Size
to>=Aac_OutputChannelPosition_Size
to prevent accessingAac_ChannelMode[43]
.