Add bounds check iChanID before array access#3810
Conversation
|
|
||
| for ( size_t iFader = 0; iFader < iNumConnectedClients; iFader++ ) | ||
| { | ||
| // ideally "iChanID" in CChannelInfo would be size_t if it can never be INVALID_INDEX |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Ok. We still need to have an int then until after the check.
Switch bounds check to use MathUtils Fix channel ID range check in audiomixerboard
8673697 to
098898b
Compare
softins
left a comment
There was a problem hiding this comment.
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? |
|
No. |
Created #3812 |
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