Skip to content

Conversation

@svc-rdkeportal01
Copy link

@svc-rdkeportal01 svc-rdkeportal01 commented Dec 2, 2025

Fix NULL_RETURNS in getEventTableInstNum

Issues Fixed

  • Coverity CID 85: NULL_RETURNS in test/rbus/provider/rbusTestProvider.c at line 1337

Root Cause

strstr() can return NULL if the substring "EventsTable." is not found in the input string. The original code adds 12 to the result without checking for NULL, then immediately dereferences it, which can cause a segmentation fault.

Changes Made

Added NULL check before using the pointer returned by strstr():

Before:

char const* pinstNum = strstr(propName, "EventsTable.") + 12;
buff[0] = *pinstNum;  // Crash if strstr returned NULL

After:

char const* pinstNum = strstr(propName, "EventsTable.");

if(!pinstNum) {
    printf("%s: EventsTable not found in %s\n", __FUNCTION__, propName);
    return 0;  // Return default value
}

pinstNum += 12;  // Move past "EventsTable."
buff[0] = *pinstNum;  // Safe to dereference now
  • Line: 1337

Coverity issue ID: 85 (line 1337)
Fix generated by RDKDevPilot AI Bot

Co-authored-by: rdkdevpilot <bot@rdkcentral.com>
@svc-rdkeportal01 svc-rdkeportal01 requested a review from a team as a code owner December 2, 2025 11:38
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.

1 participant