Skip to content

RDKB-64347: Fixing coverity issues#1062

Open
bharathivelp wants to merge 2 commits intordkcentral:developfrom
bharathivelp:RDKB_Coverity_fixes
Open

RDKB-64347: Fixing coverity issues#1062
bharathivelp wants to merge 2 commits intordkcentral:developfrom
bharathivelp:RDKB_Coverity_fixes

Conversation

@bharathivelp
Copy link
Copy Markdown
Contributor

Reason for change: Fixing high medium priority coverity issues.
Test Procedure: Build should be successful and the regression test should also succeed.
 
Risks: Low
Priority: P1
Signed-off-by: Velpula_Bharathi@comcast.com

Reason for change: Fixing high medium priority coverity issues.
Test Procedure: Build should be successful and the regression test should also succeed.
 
Risks: Low
Priority: P1
Signed-off-by: Velpula_Bharathi@comcast.com
@bharathivelp bharathivelp requested a review from a team as a code owner April 14, 2026 05:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 4 out of 4 changed files in this pull request and generated 3 comments.


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

Comment on lines +1430 to +1434
size_t current_len = strlen(assoc_maclist);
if (current_len + strlen(mac_str) + 2 <= 2048) {
strncat(assoc_maclist, mac_str, 2048 - current_len - 1);
strncat(assoc_maclist, ",", 2048 - strlen(assoc_maclist) - 1);
has_successful_operations = true;
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The buffer size 2048 is hard-coded in multiple related operations (allocation, memset, bounds check, and strncat limits). To reduce the risk of future mismatches/bugs, define a single named constant (or reuse an existing one) for the assoc MAC list buffer size and use it consistently in these calculations.

Copilot uses AI. Check for mistakes.
Comment thread source/utils/ovsh.c
Comment on lines 1268 to 1271
ovsh_where_num++;
ovsh_where_expr = (char**)realloc(ovsh_where_expr, sizeof(char*) * ovsh_where_num);
ovsh_where_expr = (char**)realloc(ovsh_where_expr, sizeof(*ovsh_where_expr) * ovsh_where_num);
assert(ovsh_where_expr);
ovsh_where_expr[ovsh_where_num-1] = strdup(_str);
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

realloc() is assigned directly to ovsh_where_expr and then only checked via assert(). If realloc() fails, the original pointer is leaked (because it gets overwritten with NULL), and in release builds with NDEBUG the assert() may be compiled out leading to a NULL dereference on the next line. Use a temporary pointer for realloc(), check for NULL, and gracefully return/goto error (also consider rolling back ovsh_where_num on failure).

Copilot uses AI. Check for mistakes.
@@ -1217,8 +1217,6 @@ int main(int argc, char *argv[])
csi_sub_index++;
g_csi_levl_sub = true;
break;
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This switch statement no longer includes a default case. The project style guide explicitly requires always including a default statement in switches (see CODE_STYLE.md “Switch statement” section). Please re-add a default: branch (even if it just breaks).

Suggested change
break;
break;
default:
break;

Copilot uses AI. Check for mistakes.
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