Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/btrCore.c
Original file line number Diff line number Diff line change
Expand Up @@ -7258,7 +7258,7 @@ btrCore_BTAdapterStatusUpdateCb (
return -1;
}

memset(&lstAdapterInfo, 0, sizeof(stBTRCoreAdapter));
memset(&lstAdapterInfo, 0, 10*sizeof(stBTRCoreAdapter));
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

The memset size is incorrect: lstAdapterInfo is a single stBTRCoreAdapter, but 10*sizeof(stBTRCoreAdapter) will overwrite adjacent stack memory (undefined behavior / potential crash or vulnerability). Use sizeof(lstAdapterInfo) (or sizeof(stBTRCoreAdapter)) as the third argument instead of scaling by 10.

Suggested change
memset(&lstAdapterInfo, 0, 10*sizeof(stBTRCoreAdapter));
memset(&lstAdapterInfo, 0, sizeof(lstAdapterInfo));

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

lstAdapterInfo.adapter_number = atoi(apstBTAdapterInfo->pcPath + pathlen-1);

BTRCORELOG_INFO ("adapter number = %d, path = %s, discovering = %d\n",
Expand Down
Loading