-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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 Global Buffer Overflow in MediaInputManager.cpp #36856
Conversation
PR #36856: Size comparison from cfdaf79 to 6ff0df9 Full report (69 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BoB13-Matter please add a Testing section to your PR summary:
how was this tested
since I see no unit tests changes, I assume this was manual. Please explain why automated testing is impossible (clusters are generally not built for unit tests ... but also why can't we have yaml or python tests?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created #36875 for testing this. The PR description does describe how to reproduce the issue so assuming manual and the delta is small.
Description
This pull request fixes a global-buffer-overflow in the
MediaInputManager::HandleRenameInput
function of the MediaInput cluster.The
mCharDataBuffer
has a fixed size of 32 for each index.However, the
memcpy
operation in theHandleRenameInput
function does not verify that thename.size()
does not exceed the buffer size. This leads to a buffer overflow when the input size is larger than 32 bytes. This is triggered by passing a string larger than 32 bytes, as demonstrated in the reproduction steps.Reproduce
Run the following commands in separate terminals:
tv-app:
chip-tool:
Execute the
rename-input
command in the MediaInput cluster with a long string argument:Observe the AddressSanitizer log for buffer overflow errors.
ASAN Log.txt
Changes
The fix introduces a size check to prevent buffer overflow. Before executing
memcpy
, it verifies that the input size (name.size()
) does not exceed the buffer size (sizeof(mCharDataBuffer[index])
). The updated function is as follows: