RDKEMW-14533 : DO NOT MERGE#69
Conversation
Reason for change: Inclusion of coverity for BT Test Procedure: NA Risks: Low Priority: P2 Signed-off-by: ppalan289 <preethi_palanisamy@comcast.com>
There was a problem hiding this comment.
Pull request overview
Updates btrCore_BTAdapterStatusUpdateCb() initialization logic, ostensibly to address Coverity findings related to BT adapter handling.
Changes:
- Modifies the
memset()size used to zero-initialize a localstBTRCoreAdapterinstance.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| memset(&lstAdapterInfo, 0, sizeof(stBTRCoreAdapter)); | ||
| memset(&lstAdapterInfo, 0, 10*sizeof(stBTRCoreAdapter)); |
There was a problem hiding this comment.
memset() is clearing 10*sizeof(stBTRCoreAdapter) bytes starting at &lstAdapterInfo, but lstAdapterInfo is a single stBTRCoreAdapter local variable. This writes past the stack object and is a memory corruption bug. Use sizeof(lstAdapterInfo) (or sizeof(stBTRCoreAdapter)) as the third argument; if an array is intended, declare an array and update all uses accordingly.
| memset(&lstAdapterInfo, 0, 10*sizeof(stBTRCoreAdapter)); | |
| memset(&lstAdapterInfo, 0, sizeof(lstAdapterInfo)); |
| } | ||
|
|
||
| memset(&lstAdapterInfo, 0, sizeof(stBTRCoreAdapter)); | ||
| memset(&lstAdapterInfo, 0, 10*sizeof(stBTRCoreAdapter)); |
There was a problem hiding this comment.
Coverity Issue - Wrong sizeof argument
Passing argument "&lstAdapterInfo" of type "stBTRCoreAdapter *" and argument "480UL" ("10UL * 48UL") to function "memset" is suspicious because "sizeof (stBTRCoreAdapter) /48/" is expected.
Medium Impact, CWE-131
SIZEOF_MISMATCH
| } | ||
|
|
||
| memset(&lstAdapterInfo, 0, sizeof(stBTRCoreAdapter)); | ||
| memset(&lstAdapterInfo, 0, 10*sizeof(stBTRCoreAdapter)); |
There was a problem hiding this comment.
Coverity Issue - Out-of-bounds access
Overrunning struct type stBTRCoreAdapter of 48 bytes by passing it to a function which accesses it at byte offset 479 using argument "480UL".
High Impact, CWE-119
OVERRUN
Reason for change: Inclusion of coverity for BT
Test Procedure: NA
Risks: Low
Priority: P2