Skip to content

RDKB-64347: Fixing coverity issues#1060

Open
vanshika-singhal24 wants to merge 1 commit intordkcentral:developfrom
vanshika-singhal24:Coverity-RDKB-64347
Open

RDKB-64347: Fixing coverity issues#1060
vanshika-singhal24 wants to merge 1 commit intordkcentral:developfrom
vanshika-singhal24:Coverity-RDKB-64347

Conversation

@vanshika-singhal24
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: vanshika_lnu@comcast.com

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


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

Comment thread source/core/wifi_ctrl_wifiapi_handlers.c
Comment thread source/core/wifi_ctrl_wifiapi_handlers.c
Comment on lines 725 to 729
snprintf(recName, sizeof(recName),BeaconRateCtl, instance_number);
retPsmSet = PSM_Set_Record_Value2(bus_handle, g_Subsystem, recName, ccsp_string, instanceNumStr);
if(retPsmSet == CCSP_SUCCESS) {
strcpy(cfg->beacon_rate_ctl, acfg->u.bss_info.beaconRateCtl);
snprintf(cfg->beacon_rate_ctl, sizeof(cfg->beacon_rate_ctl), "%s", acfg->u.bss_info.beaconRateCtl);
wifi_util_dbg_print(WIFI_PSM,"%s:%d BeaconRateCtl cfg->beacon_rate_ctl is %s\n",__func__, __LINE__,cfg->beacon_rate_ctl);
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.

In this BeaconRateCtl update block, instanceNumStr is cleared but never populated with the new BeaconRateCtl value before calling PSM_Set_Record_Value2(). As a result, the PSM record will be set to an empty string even though cfg->beacon_rate_ctl is updated from acfg->u.bss_info.beaconRateCtl. Populate instanceNumStr from acfg->u.bss_info.beaconRateCtl (and consider validating/truncation) before the PSM_Set_Record_Value2 call.

Copilot uses AI. Check for mistakes.
Comment thread source/dml/wifi_ssp/ssp_loop.c Outdated
Comment thread source/core/wifi_ctrl_wifiapi_handlers.c
Comment thread source/core/wifi_ctrl_wifiapi_handlers.c
Comment thread source/core/wifi_ctrl_wifiapi_handlers.c Outdated
Comment thread source/core/wifi_ctrl_wifiapi_handlers.c
Comment thread source/dml/wifi_ssp/ssp_loop.c Outdated
@@ -939,7 +939,7 @@ void Psm_Db_Write_Global(wifi_global_param_t *gcfg)
if(strncmp(gcfg->wifi_region_code, cfg->wifi_region_code, strlen(cfg->wifi_region_code)) != 0){
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 comparison uses strncmp(..., strlen(cfg->wifi_region_code)). If cfg->wifi_region_code is empty (len 0) this will never detect changes, and if cfg is a prefix of gcfg it can incorrectly treat values as equal. Prefer strcmp() for full-string comparison or strncmp() with a bound like sizeof(cfg->wifi_region_code).

Suggested change
if(strncmp(gcfg->wifi_region_code, cfg->wifi_region_code, strlen(cfg->wifi_region_code)) != 0){
if(strcmp(gcfg->wifi_region_code, cfg->wifi_region_code) != 0){

Copilot uses AI. Check for mistakes.
Comment thread source/core/wifi_ctrl_wifiapi_handlers.c Outdated
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 5 out of 5 changed files in this pull request and generated 1 comment.


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

Comment thread source/dml/wifi_ssp/ssp_loop.c Outdated
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 5 out of 5 changed files in this pull request and generated 1 comment.


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

Comment on lines 714 to 718
for (i=0; i < (sizeof(wifi_api_list)/sizeof(struct hal_api_info)); i++) {
if (strcmp(args[0], wifi_api_list[i].name) == 0) {
if (num_args == 0 || (num_args-1 < wifi_api_list[i].num_args)) {
sprintf(buff, "wifi_api2: Error - Invalid number of arguments\nhelp: %s %s\n",
snprintf(buff, sizeof(buff), "wifi_api2: Error - Invalid number of arguments\nhelp: %s %s\n",
wifi_api_list[i].name, wifi_api_list[i].help);
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.

process_wifiapi_command() copies len bytes into a fixed 1024-byte input buffer (via memcpy) without bounding len or guaranteeing NUL-termination before strtok_r(). Since the RBUS setter enqueues (strlen(pTmp)+1) with no max length, a long command can overflow input and corrupt memory. Add a size check (reject/return an error if len >= sizeof(input)), and do a bounded copy that always terminates the string (e.g., copy at most sizeof(input)-1 and set the last byte to '\0').

Copilot uses AI. Check for mistakes.
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 5 out of 5 changed files in this pull request and generated 2 comments.


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

Comment on lines 726 to 728
if (found == 0) {
sprintf(buff, "wifi_api2: Invalid API '%s'", args[0]);
snprintf(buff, sizeof(buff), "wifi_api2: Invalid API '%s'", args[0]);
goto publish;
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.

args[0] is used in error reporting without guaranteeing any tokens were parsed. If command is empty/whitespace, num_args stays 0 and args[0] is uninitialized, leading to undefined behavior/crash. Add an early guard after tokenization (e.g., if num_args==0) to return/publish a helpful error before referencing args[0] (and similarly avoid the later strcmp loop on args[0] in that case).

Copilot uses AI. Check for mistakes.
Comment thread source/db/wifi_db_apis.c Outdated
@@ -3543,7 +3543,7 @@ int wifidb_get_wifi_global_config(wifi_global_param_t *config)
if (strlen(pcfg->wps_pin) != 0) {
strncpy(config->wps_pin,pcfg->wps_pin,sizeof(config->wps_pin)-1);
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.

strncpy(config->wps_pin, pcfg->wps_pin, sizeof(config->wps_pin)-1) does not guarantee NUL-termination when the source string length is >= sizeof(config->wps_pin)-1. Ensure config->wps_pin[sizeof(config->wps_pin)-1] is set to '\0' (or use snprintf) to avoid unterminated strings being consumed by later string operations.

Suggested change
strncpy(config->wps_pin,pcfg->wps_pin,sizeof(config->wps_pin)-1);
snprintf(config->wps_pin, sizeof(config->wps_pin), "%s", pcfg->wps_pin);

Copilot uses AI. Check for mistakes.
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: vanshika_lnu@comcast.com
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