Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix out-of-bounds array read in File_Aac_Main #2117

Merged
merged 1 commit into from
Sep 30, 2024

Conversation

cjee21
Copy link
Contributor

@cjee21 cjee21 commented Sep 30, 2024

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

Cppcheck:

Id: arrayIndexOutOfBoundsCond
CWE: 788
Either the condition 'OutputChannels[i]>Aac_OutputChannelPosition_Size' is redundant or the array 'Aac_ChannelMode[43]' is accessed at index 43, which is out of bounds.

if (OutputChannels[i]>Aac_OutputChannelPosition_Size)
ChannelModes[Aac_ChannelMode_Max]++;
else
ChannelModes[Aac_ChannelMode[OutputChannels[i]]]++;

The issue is that Aac_OutputChannelPosition_Size is 43 and Aac_ChannelMode has 43 elements. Since an array starts with 0, the max we can access in Aac_ChannelMode is 42. So we change >Aac_OutputChannelPosition_Size to >=Aac_OutputChannelPosition_Size to prevent accessing Aac_ChannelMode[43].

@JeromeMartinez
Copy link
Member

Ouch... Good catch.
We definitely to run (again) the static analysis... Thank you for handling that.

@JeromeMartinez JeromeMartinez merged commit e7fd9f0 into MediaArea:master Sep 30, 2024
9 checks passed
@cjee21 cjee21 deleted the AAC branch September 30, 2024 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants