Repository navigation
coverity_integration_1: Fix Coverity defects (2 files) Severity [HIGH] - #92
Open
rdkdevpilot wants to merge 3 commits into
Open
rdkdevpilot wants to merge 3 commits into
rdkdevpilot wants to merge 3 commits into
Conversation
Defect ID: 9e9a9a4c-44db-4277-b0ad-77be6d088e1b
Defect ID: 6a9b57bd-0453-4cca-a4da-28dce7240d6b
There was a problem hiding this comment.
🟡 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
strcpywith 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Automated Fix for Coverity Defects
Triggered by: GomathiShankar PS
Fixed Files
c_sourcecode/src/scanner/scanner.cc_sourcecode/src/ratelimit/ratelimit.cFix Summaries
c_sourcecode/src/scanner/scanner.cBoth 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.cThe 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]andbuf[i]were accessed before the bounds checki < sizeof(...), which could result in an out-of-bounds read if the buffer was not null-terminated within bounds. By moving the bounds checki < sizeof(first_line_data)andi < 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.