Skip to content

RDKEMW-24184 : Fix coverity issues (from copilot) in subttxrend-cc - #115

Open
krithikasvraman wants to merge 4 commits into
developfrom
topic/RDKEMW-24184
Open

krithikasvraman wants to merge 4 commits into
developfrom
topic/RDKEMW-24184

Conversation

@krithikasvraman

Copy link
Copy Markdown
Contributor

Reason for change: Fix coverity issues in subttxrend-cc
Test Procedure: Regression tests
Risks: Low
Signed-off-by:krithika_venkataraman@comcast.com

Reason for change: Fix coverity issues in subttxrend-cc
Test Procedure: Regression tests
Risks: Low
Signed-off-by:krithika_venkataraman@comcast.com
Copilot AI lite review requested due to automatic review settings September 1, 2026 11:00
@krithikasvraman
krithikasvraman requested a review from a team as a code owner September 1, 2026 11:00

Copilot AI left a comment

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.

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 provided data_length and validate minimum length before reading the extended code byte.
Suppressed comments (1)

subttxrend-cc/src/CcCommandParser.cpp:682

  • handleExtChar() returns 0 when data_length < 2, which can stall processBlock() (it increments i by consumed, 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.

Comment thread subttxrend-cc/src/CcCommandParser.cpp
Reason for change: Fix coverity issues in subttxrend-cc
Test Procedure: Regression tests
Risks: Low
Signed-off-by:krithika_venkataraman@comcast.com
Copilot AI review requested due to automatic review settings September 1, 2026 12:17

Copilot AI left a comment

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.

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

  • scanForRSTDLC skips C0_EXT1 sequences using a fixed i += 2, but extended commands are variable-length (see handleExtChar/handleC2/handleC3). This can desynchronize the scan and cause false detection of C1_RST/C1_DLC inside an extended command payload, leading to unintended resets or delay cancels. Consider skipping the full extended-command length (with bounds checks) and continue the 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 == 0 break in processBlock, and handleExtChar returning 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;
	}

Comment thread subttxrend-cc/src/CcCommandParser.cpp Outdated
Comment thread subttxrend-cc/src/CcCommandParser.cpp
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 1, 2026 12:41

Copilot AI left a comment

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

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.

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() treats EXT1 as 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-detect RST/DLC inside parameter bytes, causing incorrect buffer reset/cancel behavior.
        if (data[i] == C0_EXT1)
        {
            i += 2;
            if (i >= data.size())
            {
                break;
            }
        }

Comment on lines +153 to +156
if (consumed == 0)
{
break;
}
Copilot AI review requested due to automatic review settings September 7, 2026 05:38

Copilot AI left a comment

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.

🟢 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants