Skip to content

Add bounds check iChanID before array access#3810

Open
ann0see wants to merge 1 commit into
jamulussoftware:mainfrom
ann0see:fix/oob-iChanID-audiomixerboard
Open

Add bounds check iChanID before array access#3810
ann0see wants to merge 1 commit into
jamulussoftware:mainfrom
ann0see:fix/oob-iChanID-audiomixerboard

Conversation

@ann0see

@ann0see ann0see commented Jul 20, 2026

Copy link
Copy Markdown
Member

Short description of changes

Guards iChanId to definitely be in bounds. Checking the flow revealed that there is indeed no other bounds check and we may have INVALID_INDEX (=-1) which would yield to an invalid access (found by AI review)

CHANGELOG: Resolve out of bounds access issue

Context: Fixes an issue?

No. Only discussed internally.

Does this change need documentation? What needs to be documented and how?

Status of this Pull Request

Ready for quick !! review. This is a potentially severe bug (as discussed internally)

What is missing until this pull request can be merged?

Review and testing

Checklist

  • I've verified that this Pull Request follows the general code principles
  • I tested my code and it does what I want
  • My code follows the style guide
  • I waited some time after this Pull Request was opened and all GitHub checks completed without errors.
  • I've filled all the content above

@ann0see ann0see added this to the 3.12.3 milestone Jul 20, 2026
@ann0see ann0see added this to Tracking Jul 20, 2026
@ann0see ann0see added bug Something isn't working refactoring Non-behavioural changes, Code cleanup labels Jul 20, 2026
@github-project-automation github-project-automation Bot moved this to Triage in Tracking Jul 20, 2026
@ann0see ann0see moved this from Triage to Waiting on Team in Tracking Jul 20, 2026
Comment thread src/audiomixerboard.cpp

for ( size_t iFader = 0; iFader < iNumConnectedClients; iFader++ )
{
// ideally "iChanID" in CChannelInfo would be size_t if it can never be INVALID_INDEX

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the comment was wrong.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It includes the word if. The reason it's not size_t is because size_t is unsigned. As far as I'm aware, the comment is correct.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. We still need to have an int then until after the check.

Comment thread src/audiomixerboard.cpp Outdated
Switch bounds check to use MathUtils

Fix channel ID range check in audiomixerboard
@ann0see
ann0see force-pushed the fix/oob-iChanID-audiomixerboard branch from 8673697 to 098898b Compare July 20, 2026 13:08

@softins softins left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Although as a separate thing, I would prefer to make MathUtils::InRange() inclusive only of the lower bound, and exclusive of the upper bound, so that we could have MAX_NUM_CHANNELS as the upper bound instead of MAX_NUM_CHANNELS - 1, and similarly for the only other use of InRange(), which is in server.cpp

@dingodoppelt

Copy link
Copy Markdown
Member

Looks good to me.

Although as a separate thing, I would prefer to make MathUtils::InRange() inclusive only of the lower bound, and exclusive of the upper bound, so that we could have MAX_NUM_CHANNELS as the upper bound instead of MAX_NUM_CHANNELS - 1, and similarly for the only other use of InRange(), which is in server.cpp

Can we do that as part of this PR?

@ann0see

ann0see commented Jul 20, 2026

Copy link
Copy Markdown
Member Author

No.

@dingodoppelt

Copy link
Copy Markdown
Member

No.

Created #3812

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working refactoring Non-behavioural changes, Code cleanup

Projects

Status: Waiting on Team

Development

Successfully merging this pull request may close these issues.

4 participants