Skip to content

RDKB-50706 : Resolve Coverity issues in xupnp component - #11

Open
rahul012345 wants to merge 1 commit into
rdkcentral:developfrom
rahul012345:develop
Open

RDKB-50706 : Resolve Coverity issues in xupnp component#11
rahul012345 wants to merge 1 commit into
rdkcentral:developfrom
rahul012345:develop

Conversation

@rahul012345

Copy link
Copy Markdown

Reason for change: Fixing the coverity issue
Test Procedure: Locally tested
Risks: Low
Signed-off-by:rahul.sharma4@sky.uk

@rahul012345
rahul012345 requested a review from a team as a code owner June 16, 2026 10:34
Copilot AI review requested due to automatic review settings June 16, 2026 10:34
@rahul012345
rahul012345 requested a review from a team as a code owner June 16, 2026 10:34

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.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR focuses on hardening the discovery/IDM code paths by improving string safety, memory cleanup, and list/mutex handling to reduce leaks and undefined behavior.

Changes:

  • Fixes unsafe string copies (bounds + explicit null termination) and a hashing bitwise-operation bug.
  • Adds missing frees/cleanup in multiple discovery callbacks and config parsing paths.
  • Refactors mutex usage around shared device lists and adjusts list iteration/freeing logic.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 10 comments.

File Description
src/xdiscovery.c Fixes hash folding, MAC string termination, adds cleanup in callbacks, and adjusts discovery result list handling
src/idm_server.c Replaces unsafe copies with bounded copies / safe CRT usage
src/idm_client.c Improves string safety, adds mutex protection for shared list access, and adjusts TLS interaction return behavior
broadband/lib/src/xcal-device-library.c Adds missing frees, improves pipe read handling, and strengthens parsing/error cleanup
Comments suppressed due to low confidence (1)

src/idm_client.c:1

  • The mutex is locked at line 588 but never unlocked on the success path (returns TRUE at line 619). This will deadlock other threads attempting to access xdevlist. Ensure g_mutex_unlock(mutex); is executed on all return paths (e.g., unlock just before return TRUE; or use a single exit path).
/*

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/idm_server.c Outdated
Comment on lines +303 to +305
errno_t rc = -1;
strncpy(interface,Interface,IPv4_ADDR_SIZE-1);
interface[IPv4_ADDR_SIZE-1] = '0';
Comment thread src/idm_client.c
Comment on lines +629 to 630
g_mutex_unlock(mutex);
return FALSE;
Comment thread src/idm_client.c
Comment on lines 378 to 383
{
g_tls_connection_set_certificate (connection, cert);
g_object_unref (cert);
return G_TLS_INTERACTION_HANDLED;
}
return G_TLS_INTERACTION_FAILED;
return G_TLS_INTERACTION_HANDLED;
}
Comment thread src/xdiscovery.c
Comment on lines +3374 to +3380
GList *element, *element_root;
element_root = element = g_list_first(xdevlistDup);
if(element_root == NULL) {
g_string_free(localOutputContents, TRUE);
g_string_free(logDevicesList, TRUE);
return FALSE;
}
Comment thread src/xdiscovery.c
Comment on lines +3508 to 3511
if(element_root)
g_list_free(element_root);
if(xdevlistDup)
g_list_free(xdevlistDup);
Comment thread src/xdiscovery.c
Comment on lines +415 to 417
short index, pindex, tindex;

if (((index = dpnode_lookup(ipaddr, macaddr, &stat, &pindex)) >= 0) && (index != DP_WLIST_ERROR))
Comment thread src/idm_client.c
{
int rvalue=0;
if(!(dc_obj->interface)||(dc_obj->port)==0||(dc_obj->discovery_interval)==0||(dc_obj->loss_detection_window)==0)
if((dc_obj->interface[0]=='\0')||(dc_obj->port)==0||(dc_obj->discovery_interval)==0||(dc_obj->loss_detection_window)==0)
Comment thread src/idm_client.c
Comment on lines 865 to 868
while(element)
{
GwyDeviceData *gwydata = element->data;
g_mutex_lock(mutex);
xdevlist = g_list_remove_link(xdevlist,element);
Comment thread src/idm_client.c
Comment on lines 884 to 885
element = g_list_next(element);
}
Comment thread broadband/lib/src/xcal-device-library.c Outdated
g_string_printf(data, "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x", mac[0], mac[1], mac[2],
mac[3], mac[4], mac[5]);
return data->str;
return g_string_free(data, FALSE);;
Reason for change: Fixing the coverity issue
Test Procedure: Locally tested
Risks: Low
Signed-off-by:rahul.sharma4@sky.uk
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