RDKEMW-24184 : Fix coverity issues (from copilot) in subttxrend-cc - #115
krithikasvraman wants to merge 4 commits into
Conversation
Reason for change: Fix coverity issues in subttxrend-cc Test Procedure: Regression tests Risks: Low Signed-off-by:krithika_venkataraman@comcast.com
There was a problem hiding this comment.
Pull request overview
This PR aims to address Coverity-reported issues in the subttxrend-cc closed caption command parser by adding additional bounds/length checks while scanning and parsing command bytes.
Changes:
- Add bounds handling in
scanForRSTDLC()when encountering EXT1 sequences near the end of a block. - Add early length validation in
handleC0()for 3-byte C0 commands (e.g., P16) to avoid out-of-bounds reads. - Update
handleExtChar()to use the provideddata_lengthand validate minimum length before reading the extended code byte.
Suppressed comments (1)
subttxrend-cc/src/CcCommandParser.cpp:682
handleExtChar()returns 0 whendata_length < 2, which can stallprocessBlock()(it incrementsibyconsumed, so 0 results in an infinite loop). To avoid hanging on truncated EXT1 sequences, consume the remaining bytes instead of returning 0.
if (data_length < 2)
{
return 0;
}
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Reason for change: Fix coverity issues in subttxrend-cc Test Procedure: Regression tests Risks: Low Signed-off-by:krithika_venkataraman@comcast.com
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
Suppressed comments (2)
Previously missed (1) — in code that hasn't changed since the last review.
subttxrend-cc/src/CcCommandParser.cpp:199
scanForRSTDLCskipsC0_EXT1sequences using a fixedi += 2, but extended commands are variable-length (seehandleExtChar/handleC2/handleC3). This can desynchronize the scan and cause false detection ofC1_RST/C1_DLCinside an extended command payload, leading to unintended resets or delay cancels. Consider skipping the full extended-command length (with bounds checks) andcontinuethe loop.
if (data[i] == C0_EXT1)
{
i += 2;
if (i >= data.size())
{
subttxrend-cc/src/CcCommandParser.cpp:156
- The new early-exit paths for truncated commands (
consumed == 0break inprocessBlock, andhandleExtCharreturning 0 for short buffers) should have unit tests to ensure the parser neither crashes nor hangs on malformed/truncated service blocks (e.g.,{C0_EXT1};{C0_EXT1, 0x90};{C0_P16, 0x41}etc.).
if (consumed == 0)
{
break;
}
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
subttxrend-cc/src/CcCommandParser.cpp:202
scanForRSTDLC()treatsEXT1as a fixed 2-byte sequence (i += 2), but extended commands can be longer (e.g., C2 lengths 1–4; C3 can be 5/6/variable). This can desynchronize scanning and potentially mis-detectRST/DLCinside parameter bytes, causing incorrect buffer reset/cancel behavior.
if (data[i] == C0_EXT1)
{
i += 2;
if (i >= data.size())
{
break;
}
}
| if (consumed == 0) | ||
| { | ||
| break; | ||
| } |
There was a problem hiding this comment.
🟢 Approval recommended
The changes are narrowly scoped defensive checks that mitigate concrete parsing edge cases without introducing interface changes or behavioral complexity.
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0 new
- Review effort level: Lite
Reason for change: Fix coverity issues in subttxrend-cc
Test Procedure: Regression tests
Risks: Low
Signed-off-by:krithika_venkataraman@comcast.com