Skip to content

coverity_integration_1: Fix Coverity defects (2 files) Severity [HIGH] - #92

Open
rdkdevpilot wants to merge 3 commits into
developfrom
topic/coverity_integration_1
Open

rdkdevpilot wants to merge 3 commits into
developfrom
topic/coverity_integration_1

Conversation

@rdkdevpilot

Copy link
Copy Markdown

Automated Fix for Coverity Defects

Triggered by: GomathiShankar PS

Fixed Files

File Line(s) CIDs Checker Types Description
c_sourcecode/src/scanner/scanner.c L610, L765 68705, 68698 OVERRUN, STRING_OVERFLOW Destination buffer too small, Out-of-bounds access
c_sourcecode/src/ratelimit/ratelimit.c L124, L200 68700, 68701 OVERRUN Out-of-bounds read

Fix Summaries

c_sourcecode/src/scanner/scanner.c

Both changes correctly address the OVERRUN defect. The first change tightens the bounds check for pnamelen from sizeof(ProcessName) (512) to sizeof(containerName) (256), which is the actual source buffer size and the true upper bound of the pointer-difference calculation. The second change replaces an unsafe strcpy with a bounded strncpy plus explicit null termination to prevent potential buffer overrun when copying newfull into fullpath. Neither change introduces new defects or breaks existing logic.

c_sourcecode/src/ratelimit/ratelimit.c

The fix correctly addresses the out-of-bounds read defect by reordering the loop conditions in both for-loops. In the original code, first_line_data[i] and buf[i] were accessed before the bounds check i < sizeof(...), which could result in an out-of-bounds read if the buffer was not null-terminated within bounds. By moving the bounds check i < sizeof(first_line_data) and i < sizeof(buf) to be evaluated first (short-circuit evaluation), the fix ensures the index is valid before accessing the array element. The change is minimal (only the condition ordering is changed), preserves all existing logic, introduces no new defects, and correctly resolves the Coverity OVERRUN defect. Both buffers are stack-allocated with known sizes, so sizeof() is appropriate here.

Defect ID: 9e9a9a4c-44db-4277-b0ad-77be6d088e1b
Defect ID: 6a9b57bd-0453-4cca-a4da-28dce7240d6b
@rdkdevpilot
rdkdevpilot requested a review from a team as a code owner October 22, 2026 07:32
Copilot AI balanced review requested due to automatic review settings October 22, 2026 07:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The renamed-path copy can write beyond smaller caller-owned buffers because it assumes a 512-byte destination.

1 open issue
What changed in this PR

This PR addresses Coverity buffer-bound findings in crash scanning and upload rate-limit validation.

Changes:

  • Bounds the process-name copy using the source buffer size.
  • Replaces the renamed-path strcpy with a fixed-limit copy and explicit terminator.
  • Checks array bounds before reading characters in two rate-limit validation loops.
File Description
c_sourcecode/​src/​scanner/​scanner.c Adjusts process-name bounds and renamed-path copying.
c_sourcecode/​src/​ratelimit/​ratelimit.c Moves bounds checks ahead of array access.

Review effort: Balanced

Comment thread c_sourcecode/src/scanner/scanner.c Outdated
Copilot AI balanced review requested due to automatic review settings October 22, 2026 10:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The bounds fixes and corresponding API updates are consistent, with no unresolved blocking issues identified.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@gomathishankar37 gomathishankar37 changed the title coverity_integration_1: Fix Coverity defects (2 files) coverity_integration_1: Fix Coverity defects (2 files) Severity [HIGH] Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants