Skip to content

RDKEMW-22210: Fix coverity issues on xdial - #211

Open
balav08 wants to merge 2 commits into
developfrom
feature/RDKEMW-22210
Open

RDKEMW-22210: Fix coverity issues on xdial#211
balav08 wants to merge 2 commits into
developfrom
feature/RDKEMW-22210

Conversation

@balav08

@balav08 balav08 commented Jul 23, 2026

Copy link
Copy Markdown

Reason for change: Fixing coverity reported issues.
Test Procedure: Refer ticket.
Risks: Low
Priority: P1
version: minor

Reason for change: Fixing coverity reported issues.
Test Procedure: Refer ticket.
Risks: Low
Priority: P1
version: minor

Signed-off-by: balaji velmurugan <balaji_velmurugan@comcast.com>
Copilot AI review requested due to automatic review settings July 23, 2026 10:38
@balav08
balav08 requested a review from a team as a code owner July 23, 2026 10:38

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

This PR targets Coverity-reported issues in the xdial server implementation, primarily by adding NULL checks and tightening memory/resource handling in the REST and SSDP paths.

Changes:

  • Add NULL-guarding around request payload logging and additional-data URL escaping in the libsoup 3.0 REST POST handler.
  • Free an allocated handler path string in the libsoup 2.4 SSDP initialization path to address a resource leak.
  • Add a NULL check around gdial_app_state_to_string() usage when building the app state XML response.

Reviewed changes

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

File Description
server/libsoup/3.0/gdial-rest.c Adds Coverity-driven NULL checks and adjusts string initialization in response builder logic.
server/libsoup/2.4/gdial-ssdp.c Frees dail_ssdp_handler after handler registration to address a reported leak.
server/gdial-app.c Guards against NULL state string when creating the <state> XML node.

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

Comment on lines +436 to +438
// coverity fix : FORWARD_NULL - check for NULL request_body->data before using in log
const char *payload_str = (request_body && request_body->data) ? request_body->data : "";
GDIAL_LOGERROR("Starting the app with payload %.*s", (int)request_body->length, payload_str);
Comment on lines +503 to +504
if (additional_data_url_safe) free(additional_data_url_safe);
if (additional_data_url) g_free(additional_data_url);
Comment thread server/gdial-app.c
Comment on lines +532 to +534
// coverity fix : USE_AFTER_FREE - check for NULL before using state_str
const gchar *state_str = gdial_app_state_to_string(state);
if (state_str) {
Copilot AI review requested due to automatic review settings August 3, 2026 09:24

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Suppressed comments (3)

server/libsoup/3.0/gdial-rest.c:438

  • payload_str is guarded, but the log still uses request_body->length even when request_body->data is NULL. With %.*s, a non-zero length would cause an out-of-bounds read from the empty string (and potentially log unrelated memory). Compute the length only when request_body and request_body->data are present (otherwise use 0).
  // coverity fix : FORWARD_NULL - check for NULL request_body->data before using in log
  const char *payload_str = (request_body && request_body->data) ? request_body->data : "";
  GDIAL_LOGERROR("Starting the app with payload %.*s", (int)request_body->length, payload_str);

server/libsoup/3.0/gdial-rest.c:503

  • additional_data_url_safe comes from g_uri_escape_string(), which returns GLib-allocated memory intended to be released with g_free(). Using free() can be incorrect on builds where GLib's allocator differs from libc.
    if (additional_data_url_safe) free(additional_data_url_safe);

server/libsoup/3.0/gdial-rest.c:469

  • request_body is treated as nullable in this function (e.g., the earlier if (request_body && request_body->data && request_body->length)), but later request_body->data is accessed unconditionally when setting payload. If request_body is NULL, this will crash before the subsequent if (payload && strlen(payload)) guard runs.
    // coverity fix : FORWARD_NULL - check for NULL before calling g_uri_escape_string
    gchar *additional_data_url_safe = additional_data_url ? g_uri_escape_string(additional_data_url, NULL, FALSE) : NULL;
    GDIAL_LOGINFO("additionalDataUrl = %s, %s", additional_data_url ? additional_data_url : "(null)", additional_data_url_safe ? additional_data_url_safe : "(null)");

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.

3 participants