-
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 unbounded stack in emberAfPrintBuffer() #4633
Conversation
#### Problem emberAfPrintBuffer() allocates stack space based on an argument, with no upper bound. This could lead to stack exhaustion on small devices. #### Summary of Changes Print long buffers in multiple segments. Fixes project-chip#3662 - Unbounded stack in emberAfPrintBuffer()
// TODO: issue #3662 - Unbounded stack in emberAfPrintBuffer() | ||
#pragma GCC diagnostic push | ||
#pragma GCC diagnostic ignored "-Wstack-usage=" | ||
|
||
void emberAfPrintBuffer(int category, const uint8_t * buffer, uint16_t length, bool withSpace) |
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.
Is there a way we could unit test this? Maybe add a TODO PR (I think I wanted to do app/util unit tests before and failed, so it does not seem fair to ask you do do it as part of this PR).
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.
Added TODO. I did verify the change out-of-tree with a #define emberAfPrint(c,...) printf(__VA_ARGS__)
.
Size increase report for "esp32-example-build" from fcc0e36
Full report output
|
Size increase report for "nrfconnect-example-build" from fcc0e36
Full report output
|
* Fix unbounded stack in emberAfPrintBuffer() #### Problem emberAfPrintBuffer() allocates stack space based on an argument, with no upper bound. This could lead to stack exhaustion on small devices. #### Summary of Changes Print long buffers in multiple segments. Fixes project-chip#3662 - Unbounded stack in emberAfPrintBuffer() * Use CHIP_DEVICE_CONFIG_LOG_MESSAGE_MAX_SIZE for buffer size * TODO * casts
* Fix unbounded stack in emberAfPrintBuffer() #### Problem emberAfPrintBuffer() allocates stack space based on an argument, with no upper bound. This could lead to stack exhaustion on small devices. #### Summary of Changes Print long buffers in multiple segments. Fixes project-chip#3662 - Unbounded stack in emberAfPrintBuffer() * Use CHIP_DEVICE_CONFIG_LOG_MESSAGE_MAX_SIZE for buffer size * TODO * casts
* Fix unbounded stack in emberAfPrintBuffer() #### Problem emberAfPrintBuffer() allocates stack space based on an argument, with no upper bound. This could lead to stack exhaustion on small devices. #### Summary of Changes Print long buffers in multiple segments. Fixes project-chip#3662 - Unbounded stack in emberAfPrintBuffer() * Use CHIP_DEVICE_CONFIG_LOG_MESSAGE_MAX_SIZE for buffer size * TODO * casts
* Fix unbounded stack in emberAfPrintBuffer() #### Problem emberAfPrintBuffer() allocates stack space based on an argument, with no upper bound. This could lead to stack exhaustion on small devices. #### Summary of Changes Print long buffers in multiple segments. Fixes project-chip#3662 - Unbounded stack in emberAfPrintBuffer() * Use CHIP_DEVICE_CONFIG_LOG_MESSAGE_MAX_SIZE for buffer size * TODO * casts
Problem
emberAfPrintBuffer()
allocates stack space based on an argument, withno upper bound. This could lead to stack exhaustion on small devices.
Summary of Changes
Print long buffers in multiple segments.
Fixes #3662 - Unbounded stack in emberAfPrintBuffer()