From ea3a69df31674f5712a7ba13265b6e7e02dce1b5 Mon Sep 17 00:00:00 2001 From: Vismal S Kumar Date: Thu, 12 Mar 2026 11:09:16 +0530 Subject: [PATCH 01/18] Update Device_WiFi_SSID.cpp --- src/hostif/profiles/wifi/Device_WiFi_SSID.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp b/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp index 6c9e82096..1bfc774e6 100644 --- a/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp +++ b/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp @@ -220,7 +220,19 @@ int hostIf_WiFi_SSID::get_Device_WiFi_SSID_Fields(int ssidIndex) { ERR_CHK(rc); } - } + if (ssid && cJSON_IsString(ssid) && ssid->valuestring != NULL) + { + rc = strcpy_s(name, sizeof(name), ssid->valuestring); + if (rc != EOK) + { + ERR_CHK(rc); + } + } + else + { + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: Invalid or missing SSID in JSON\n", __FUNCTION__); + } + } else { RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] json parse error, no \"result\" in the output from Thunder plugin\n", __FUNCTION__); From 3c1b28be6a30345334a119c17d21b3e7529bf6c1 Mon Sep 17 00:00:00 2001 From: Vismal S Kumar Date: Thu, 12 Mar 2026 11:56:28 +0530 Subject: [PATCH 02/18] Update Device_WiFi_SSID.cpp --- src/hostif/profiles/wifi/Device_WiFi_SSID.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp b/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp index 1bfc774e6..9966cf579 100644 --- a/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp +++ b/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp @@ -220,18 +220,18 @@ int hostIf_WiFi_SSID::get_Device_WiFi_SSID_Fields(int ssidIndex) { ERR_CHK(rc); } - if (ssid && cJSON_IsString(ssid) && ssid->valuestring != NULL) + if (!ssid || !cJSON_IsString(ssid) || !ssid->valuestring ) { - rc = strcpy_s(name, sizeof(name), ssid->valuestring); + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: Invalid or missing SSID\n", __FUNCTION__); + cJSON_Delete(root); + return NOK; + } + rc = strcpy_s(name, sizeof(name), ssid->valuestring); if (rc != EOK) { ERR_CHK(rc); } - } - else - { - RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: Invalid or missing SSID in JSON\n", __FUNCTION__); - } + } else { From c8f69ab0c17aaa7829efa1cca1ca82731bfa285a Mon Sep 17 00:00:00 2001 From: Vismal S Kumar Date: Thu, 12 Mar 2026 14:05:33 +0530 Subject: [PATCH 03/18] Update Device_WiFi_EndPoint.cpp --- .../profiles/wifi/Device_WiFi_EndPoint.cpp | 53 ++++--------------- 1 file changed, 9 insertions(+), 44 deletions(-) diff --git a/src/hostif/profiles/wifi/Device_WiFi_EndPoint.cpp b/src/hostif/profiles/wifi/Device_WiFi_EndPoint.cpp index 628d76742..39598dfa2 100644 --- a/src/hostif/profiles/wifi/Device_WiFi_EndPoint.cpp +++ b/src/hostif/profiles/wifi/Device_WiFi_EndPoint.cpp @@ -490,58 +490,24 @@ int hostIf_WiFi_EndPoint::refreshCache() if (jsonObj) { cJSON *ssid = cJSON_GetObjectItem(jsonObj, "ssid"); + cJSON *strength = cJSON_GetObjectItem(jsonObj, "strength"); if (!(cJSON_IsString(ssid) && ssid->valuestring)) { RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] ConnectedSSID result missing valid ssid\n", __FUNCTION__); cJSON_Delete(root); return NOK; } - //ASSIGN TO OP HERE - strncpy (SSIDReference, ssid->valuestring, BUFF_LENGTH_256); - SSIDReference[BUFF_LENGTH_256 - 1] = '\0'; - } - else - { - RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] json parse error, no \"result\" in the output from Thunder plugin\n", __FUNCTION__); - cJSON_Delete(root); - return NOK; - } - cJSON_Delete(root); - } - else - { - RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: json parse error\n", __FUNCTION__); - return NOK; - } - } - else - { - RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: getJsonRPCData() failed or returned empty response\n", __FUNCTION__); - return NOK; - } - - postData = "{\"jsonrpc\":\"2.0\",\"id\":\"42\",\"method\": \"org.rdk.NetworkManager.GetWiFiSignalStrength\"}"; - response = getJsonRPCData(std::move(postData)); - - if(!response.empty()) - { - RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: curl response string = %s\n", __FUNCTION__, response.c_str()); - cJSON* root = cJSON_Parse(response.c_str()); - if(root) - { - cJSON* jsonObj = cJSON_GetObjectItem(root, "result"); - - if (jsonObj) - { - cJSON *sigstr = cJSON_GetObjectItem(jsonObj, "signalStrength"); - if (!cJSON_IsNumber(sigstr)) + if (!cJSON_IsNumber(strength)) { - RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] GetWiFiSignalStrength result missing numeric signalStrength\n", __FUNCTION__); + RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] ConnectedSSID result missing numeric strength\n", __FUNCTION__); cJSON_Delete(root); return NOK; } //ASSIGN TO OP HERE - stats.SignalStrength = sigstr->valueint; + strncpy (SSIDReference, ssid->valuestring, BUFF_LENGTH_256); + SSIDReference[BUFF_LENGTH_256 - 1] = '\0'; + stats.SignalStrength = strength->valueint; + RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: strength = %d\n", __FUNCTION__, stats.SignalStrength); } else { @@ -559,10 +525,9 @@ int hostIf_WiFi_EndPoint::refreshCache() } else { - RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: getJsonRPCData() failed or returned empty response\n", __FUNCTION__); - return NOK; + RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: getJsonRPCData() failed or returned empty response\n", __FUNCTION__); + return NOK; } - time_of_last_successful_query = time (0); //strncpy (Alias, param.data.endPointInfo.alias, BUFF_LENGTH_64); From 3730abf6a7e334e597176a5b91ce286ac035f2c9 Mon Sep 17 00:00:00 2001 From: Vismal S Kumar Date: Thu, 12 Mar 2026 14:11:24 +0530 Subject: [PATCH 04/18] Update Device_WiFi_SSID.cpp --- src/hostif/profiles/wifi/Device_WiFi_SSID.cpp | 66 +++++++++++++++---- 1 file changed, 55 insertions(+), 11 deletions(-) diff --git a/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp b/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp index 9966cf579..03af807d7 100644 --- a/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp +++ b/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp @@ -207,7 +207,21 @@ int hostIf_WiFi_SSID::get_Device_WiFi_SSID_Fields(int ssidIndex) if (jsonObj) { cJSON *bssid = cJSON_GetObjectItem(jsonObj, "bssid"); - cJSON *ssid = cJSON_GetObjectItem(jsonObj, "ssid"); + cJSON *ssid = cJSON_GetObjectItem(jsonObj, "ssid"); + + if (!bssid || !cJSON_IsString(bssid) || !bssid->valuestring) + { + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: Invalid or missing BSSID\n", __FUNCTION__); + cJSON_Delete(root); + return NOK; + } + + if (!ssid || !cJSON_IsString(ssid) || !ssid->valuestring ) + { + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: Invalid or missing SSID\n", __FUNCTION__); + cJSON_Delete(root); + return NOK; + } //ASSIGN TO OP HERE rc=strcpy_s(BSSID,sizeof(BSSID),bssid->valuestring); RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: BSSID = %s \n", __FUNCTION__, BSSID); @@ -220,12 +234,6 @@ int hostIf_WiFi_SSID::get_Device_WiFi_SSID_Fields(int ssidIndex) { ERR_CHK(rc); } - if (!ssid || !cJSON_IsString(ssid) || !ssid->valuestring ) - { - RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: Invalid or missing SSID\n", __FUNCTION__); - cJSON_Delete(root); - return NOK; - } rc = strcpy_s(name, sizeof(name), ssid->valuestring); if (rc != EOK) { @@ -256,7 +264,7 @@ int hostIf_WiFi_SSID::get_Device_WiFi_SSID_Fields(int ssidIndex) postData = "{\"jsonrpc\":\"2.0\",\"id\":\"42\",\"method\": \"org.rdk.NetworkManager.GetAvailableInterfaces\"}"; response = getJsonRPCData(postData); - if(response.c_str()) + if(!response.empty()) { RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: curl response string = %s\n", __FUNCTION__, response.c_str()); cJSON* root = cJSON_Parse(response.c_str()); @@ -270,16 +278,39 @@ int hostIf_WiFi_SSID::get_Device_WiFi_SSID_Fields(int ssidIndex) cJSON *interface = NULL; cJSON *interfaceType = NULL; - for (int i = 0; i < cJSON_GetArraySize(interfaces); i++) { + if (!cJSON_IsArray(interfaces)) + { + RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: Invalid or missing interfaces array\n", __FUNCTION__); + cJSON_Delete(root); + return NOK; + } + + for (int i = 0; i < cJSON_GetArraySize(interfaces); i++) { interface = cJSON_GetArrayItem(interfaces, i); + if (!cJSON_IsObject(interface)) + continue; interfaceType = cJSON_GetObjectItem(interface, "type"); - if (strcmp(interfaceType->valuestring, "WIFI") == 0) { + if (cJSON_IsString(interfaceType) && interfaceType->valuestring && (strcmp(interfaceType->valuestring, "WIFI") == 0)) { RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: Found WiFi Interface\n", __FUNCTION__); break; } + interface = NULL; } + + if (!interface) + { + RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: WIFI interface not found\n", __FUNCTION__); + cJSON_Delete(root); + return NOK; + } //ASSIGN TO OP HERE cJSON *result = cJSON_GetObjectItem(interface, "mac"); + if (!cJSON_IsString(result) || !result->valuestring) + { + RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: Invalid or missing mac\n", __FUNCTION__); + cJSON_Delete(root); + return NOK; + } rc=strcpy_s(MACAddress,sizeof(MACAddress),result->valuestring); RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: MACAddress = %s \n", __FUNCTION__, MACAddress); if(rc!=EOK) @@ -287,7 +318,20 @@ int hostIf_WiFi_SSID::get_Device_WiFi_SSID_Fields(int ssidIndex) ERR_CHK(rc); } cJSON *isEnabled = cJSON_GetObjectItem(interface, "enabled"); - enable=isEnabled->type; + if (cJSON_IsBool(isEnabled)) + { + enable = cJSON_IsTrue(isEnabled); + } + else if (cJSON_IsNumber(isEnabled)) + { + enable = (0 != isEnabled->valueint); + } + else + { + RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: Invalid or missing enabled\n", __FUNCTION__); + cJSON_Delete(root); + return NOK; + } RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: ENABLE = %d \n", __FUNCTION__, enable); } else From a7cb7e7afaf26ca5484f5ec56d78da8cc76953ba Mon Sep 17 00:00:00 2001 From: Vismal S Kumar Date: Thu, 12 Mar 2026 14:23:15 +0530 Subject: [PATCH 05/18] Update src/hostif/profiles/wifi/Device_WiFi_SSID.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/hostif/profiles/wifi/Device_WiFi_SSID.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp b/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp index 03af807d7..d0224e178 100644 --- a/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp +++ b/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp @@ -287,8 +287,10 @@ int hostIf_WiFi_SSID::get_Device_WiFi_SSID_Fields(int ssidIndex) for (int i = 0; i < cJSON_GetArraySize(interfaces); i++) { interface = cJSON_GetArrayItem(interfaces, i); - if (!cJSON_IsObject(interface)) + if (!cJSON_IsObject(interface)) { + interface = NULL; continue; + } interfaceType = cJSON_GetObjectItem(interface, "type"); if (cJSON_IsString(interfaceType) && interfaceType->valuestring && (strcmp(interfaceType->valuestring, "WIFI") == 0)) { RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: Found WiFi Interface\n", __FUNCTION__); From edda0133448e2be1f69e5ef3a4ade6962f7d757e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Mar 2026 08:57:06 +0000 Subject: [PATCH 06/18] Initial plan From 695abe4395c4f651de6107fe123a9a60dc56fe0c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Mar 2026 08:57:39 +0000 Subject: [PATCH 07/18] Initial plan From ffca495be43ff7eb8391981c142a06d720155728 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Mar 2026 09:00:57 +0000 Subject: [PATCH 08/18] Fix response.c_str() checks to use !response.empty() in Device_WiFi_SSID.cpp Co-authored-by: Vismalskumar0 <188226757+Vismalskumar0@users.noreply.github.com> --- src/hostif/profiles/wifi/Device_WiFi_SSID.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp b/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp index d0224e178..e62ea0fe0 100644 --- a/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp +++ b/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp @@ -196,7 +196,7 @@ int hostIf_WiFi_SSID::get_Device_WiFi_SSID_Fields(int ssidIndex) { std::string postData = "{\"jsonrpc\":\"2.0\",\"id\":\"42\",\"method\": \"org.rdk.NetworkManager.GetConnectedSSID\"}"; string response = getJsonRPCData(std::move(postData)); - if(response.c_str()) + if(!response.empty()) { RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: curl response string = %s\n", __FUNCTION__, response.c_str()); cJSON* root = cJSON_Parse(response.c_str()); @@ -359,7 +359,7 @@ int hostIf_WiFi_SSID::get_Device_WiFi_SSID_Fields(int ssidIndex) postData = "{\"jsonrpc\":\"2.0\",\"id\":\"42\",\"method\": \"org.rdk.NetworkManager.GetWifiState\"}"; response = getJsonRPCData(std::move(postData)); - if(response.c_str()) + if(!response.empty()) { RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: curl response string = %s\n", __FUNCTION__, response.c_str()); cJSON* root = cJSON_Parse(response.c_str()); From da16047d0a7203f976633d99e57b4a3f37e99020 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Mar 2026 09:03:58 +0000 Subject: [PATCH 09/18] Fix inconsistent indentation in Device_WiFi_SSID.cpp parsing block Co-authored-by: Vismalskumar0 <188226757+Vismalskumar0@users.noreply.github.com> --- src/hostif/profiles/wifi/Device_WiFi_SSID.cpp | 113 +++++++++--------- 1 file changed, 58 insertions(+), 55 deletions(-) diff --git a/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp b/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp index d0224e178..c4f01f213 100644 --- a/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp +++ b/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp @@ -275,66 +275,69 @@ int hostIf_WiFi_SSID::get_Device_WiFi_SSID_Fields(int ssidIndex) if (jsonObj) { cJSON *interfaces = cJSON_GetObjectItem(jsonObj, "interfaces"); - cJSON *interface = NULL; - cJSON *interfaceType = NULL; + cJSON *interface = NULL; + cJSON *interfaceType = NULL; - if (!cJSON_IsArray(interfaces)) - { - RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: Invalid or missing interfaces array\n", __FUNCTION__); - cJSON_Delete(root); - return NOK; - } + if (!cJSON_IsArray(interfaces)) + { + RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: Invalid or missing interfaces array\n", __FUNCTION__); + cJSON_Delete(root); + return NOK; + } - for (int i = 0; i < cJSON_GetArraySize(interfaces); i++) { + for (int i = 0; i < cJSON_GetArraySize(interfaces); i++) + { interface = cJSON_GetArrayItem(interfaces, i); - if (!cJSON_IsObject(interface)) { - interface = NULL; - continue; - } - interfaceType = cJSON_GetObjectItem(interface, "type"); - if (cJSON_IsString(interfaceType) && interfaceType->valuestring && (strcmp(interfaceType->valuestring, "WIFI") == 0)) { - RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: Found WiFi Interface\n", __FUNCTION__); - break; - } - interface = NULL; - } + if (!cJSON_IsObject(interface)) + { + interface = NULL; + continue; + } + interfaceType = cJSON_GetObjectItem(interface, "type"); + if (cJSON_IsString(interfaceType) && interfaceType->valuestring && (strcmp(interfaceType->valuestring, "WIFI") == 0)) + { + RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: Found WiFi Interface\n", __FUNCTION__); + break; + } + interface = NULL; + } - if (!interface) - { - RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: WIFI interface not found\n", __FUNCTION__); - cJSON_Delete(root); - return NOK; - } + if (!interface) + { + RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: WIFI interface not found\n", __FUNCTION__); + cJSON_Delete(root); + return NOK; + } //ASSIGN TO OP HERE - cJSON *result = cJSON_GetObjectItem(interface, "mac"); - if (!cJSON_IsString(result) || !result->valuestring) - { - RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: Invalid or missing mac\n", __FUNCTION__); - cJSON_Delete(root); - return NOK; - } - rc=strcpy_s(MACAddress,sizeof(MACAddress),result->valuestring); - RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: MACAddress = %s \n", __FUNCTION__, MACAddress); - if(rc!=EOK) - { - ERR_CHK(rc); - } - cJSON *isEnabled = cJSON_GetObjectItem(interface, "enabled"); - if (cJSON_IsBool(isEnabled)) - { - enable = cJSON_IsTrue(isEnabled); - } - else if (cJSON_IsNumber(isEnabled)) - { - enable = (0 != isEnabled->valueint); - } - else - { - RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: Invalid or missing enabled\n", __FUNCTION__); - cJSON_Delete(root); - return NOK; - } - RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: ENABLE = %d \n", __FUNCTION__, enable); + cJSON *result = cJSON_GetObjectItem(interface, "mac"); + if (!cJSON_IsString(result) || !result->valuestring) + { + RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: Invalid or missing mac\n", __FUNCTION__); + cJSON_Delete(root); + return NOK; + } + rc = strcpy_s(MACAddress, sizeof(MACAddress), result->valuestring); + RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: MACAddress = %s \n", __FUNCTION__, MACAddress); + if (rc != EOK) + { + ERR_CHK(rc); + } + cJSON *isEnabled = cJSON_GetObjectItem(interface, "enabled"); + if (cJSON_IsBool(isEnabled)) + { + enable = cJSON_IsTrue(isEnabled); + } + else if (cJSON_IsNumber(isEnabled)) + { + enable = (0 != isEnabled->valueint); + } + else + { + RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: Invalid or missing enabled\n", __FUNCTION__); + cJSON_Delete(root); + return NOK; + } + RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: ENABLE = %d \n", __FUNCTION__, enable); } else { From 0d74bc36861af8046f5fb48d3766a127519f656d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Mar 2026 10:37:02 +0000 Subject: [PATCH 10/18] Initial plan From c67f068881603d2bfdb7dd7c1b92ae585669a5b2 Mon Sep 17 00:00:00 2001 From: Vismal S Kumar Date: Thu, 12 Mar 2026 16:07:43 +0530 Subject: [PATCH 11/18] Update src/hostif/profiles/wifi/Device_WiFi_SSID.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/hostif/profiles/wifi/Device_WiFi_SSID.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp b/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp index 2b700a40f..4152f1eb0 100644 --- a/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp +++ b/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp @@ -196,6 +196,11 @@ int hostIf_WiFi_SSID::get_Device_WiFi_SSID_Fields(int ssidIndex) { std::string postData = "{\"jsonrpc\":\"2.0\",\"id\":\"42\",\"method\": \"org.rdk.NetworkManager.GetConnectedSSID\"}"; string response = getJsonRPCData(std::move(postData)); + if (response.empty()) + { + RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: Empty response received from NetworkManager.GetConnectedSSID JSON-RPC request\n", __FUNCTION__); + return NOK; + } if(!response.empty()) { RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: curl response string = %s\n", __FUNCTION__, response.c_str()); From 85fd7c6a57b704f2eba5cde50bbcad9533a7081a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Mar 2026 10:43:37 +0000 Subject: [PATCH 12/18] Initial plan From 27181e80a7fe6a72cec786fd8f1c53e095b1c476 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Mar 2026 10:47:54 +0000 Subject: [PATCH 13/18] Remove redundant response.empty() check and unreachable else branch Co-authored-by: Vismalskumar0 <188226757+Vismalskumar0@users.noreply.github.com> --- src/hostif/profiles/wifi/Device_WiFi_SSID.cpp | 89 +++++++++---------- 1 file changed, 40 insertions(+), 49 deletions(-) diff --git a/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp b/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp index 4152f1eb0..ffe855984 100644 --- a/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp +++ b/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp @@ -201,68 +201,59 @@ int hostIf_WiFi_SSID::get_Device_WiFi_SSID_Fields(int ssidIndex) RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: Empty response received from NetworkManager.GetConnectedSSID JSON-RPC request\n", __FUNCTION__); return NOK; } - if(!response.empty()) + RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: curl response string = %s\n", __FUNCTION__, response.c_str()); + cJSON* root = cJSON_Parse(response.c_str()); + if(root) { - RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: curl response string = %s\n", __FUNCTION__, response.c_str()); - cJSON* root = cJSON_Parse(response.c_str()); - if(root) - { - cJSON* jsonObj = cJSON_GetObjectItem(root, "result"); + cJSON* jsonObj = cJSON_GetObjectItem(root, "result"); - if (jsonObj) - { - cJSON *bssid = cJSON_GetObjectItem(jsonObj, "bssid"); + if (jsonObj) + { + cJSON *bssid = cJSON_GetObjectItem(jsonObj, "bssid"); cJSON *ssid = cJSON_GetObjectItem(jsonObj, "ssid"); - if (!bssid || !cJSON_IsString(bssid) || !bssid->valuestring) - { - RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: Invalid or missing BSSID\n", __FUNCTION__); - cJSON_Delete(root); - return NOK; - } + if (!bssid || !cJSON_IsString(bssid) || !bssid->valuestring) + { + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: Invalid or missing BSSID\n", __FUNCTION__); + cJSON_Delete(root); + return NOK; + } - if (!ssid || !cJSON_IsString(ssid) || !ssid->valuestring ) - { - RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: Invalid or missing SSID\n", __FUNCTION__); - cJSON_Delete(root); - return NOK; - } - //ASSIGN TO OP HERE - rc=strcpy_s(BSSID,sizeof(BSSID),bssid->valuestring); - RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: BSSID = %s \n", __FUNCTION__, BSSID); - if(rc!=EOK) - { - ERR_CHK(rc); - } - rc=strcpy_s(SSID,sizeof(SSID),ssid->valuestring); - if(rc!=EOK) - { - ERR_CHK(rc); - } - rc = strcpy_s(name, sizeof(name), ssid->valuestring); - if (rc != EOK) - { - ERR_CHK(rc); - } - - } - else - { - RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] json parse error, no \"result\" in the output from Thunder plugin\n", __FUNCTION__); + if (!ssid || !cJSON_IsString(ssid) || !ssid->valuestring) + { + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: Invalid or missing SSID\n", __FUNCTION__); cJSON_Delete(root); return NOK; - } - cJSON_Delete(root); - } + } + //ASSIGN TO OP HERE + rc=strcpy_s(BSSID,sizeof(BSSID),bssid->valuestring); + RDK_LOG (RDK_LOG_INFO, LOG_TR69HOSTIF, "%s: BSSID = %s \n", __FUNCTION__, BSSID); + if(rc!=EOK) + { + ERR_CHK(rc); + } + rc=strcpy_s(SSID,sizeof(SSID),ssid->valuestring); + if(rc!=EOK) + { + ERR_CHK(rc); + } + rc = strcpy_s(name, sizeof(name), ssid->valuestring); + if (rc != EOK) + { + ERR_CHK(rc); + } + } else { - RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: json parse error\n", __FUNCTION__); + RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] json parse error, no \"result\" in the output from Thunder plugin\n", __FUNCTION__); + cJSON_Delete(root); return NOK; } - } + cJSON_Delete(root); + } else { - RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: curl init failed\n", __FUNCTION__); + RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: json parse error\n", __FUNCTION__); return NOK; } From 2f2043ecd2949fb82597b2bd4dd13256b2dedfdd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Mar 2026 10:52:22 +0000 Subject: [PATCH 14/18] Initial plan From 67e4d577fede4f2797ade946c4a37022672a44b8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Mar 2026 10:56:08 +0000 Subject: [PATCH 15/18] Fix misleading "curl init failed" error log to "getJsonRPCData() failed" Co-authored-by: Vismalskumar0 <188226757+Vismalskumar0@users.noreply.github.com> --- src/hostif/profiles/wifi/Device_WiFi_SSID.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp b/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp index ffe855984..ab90912d4 100644 --- a/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp +++ b/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp @@ -351,7 +351,7 @@ int hostIf_WiFi_SSID::get_Device_WiFi_SSID_Fields(int ssidIndex) } else { - RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: curl init failed\n", __FUNCTION__); + RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: getJsonRPCData() failed\n", __FUNCTION__); return NOK; } From 147404e93c6d2a40949c2c19f07782e511c32b38 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Mar 2026 11:05:36 +0000 Subject: [PATCH 16/18] Initial plan From 58bd5a1cb0564df5804dab8133bd71a4b0251acd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Mar 2026 11:10:25 +0000 Subject: [PATCH 17/18] Add null and type check for state cJSON item before valueint access in GetWifiState Co-authored-by: Vismalskumar0 <188226757+Vismalskumar0@users.noreply.github.com> --- src/hostif/profiles/wifi/Device_WiFi_SSID.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp b/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp index ab90912d4..e37c4810d 100644 --- a/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp +++ b/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp @@ -368,10 +368,15 @@ int hostIf_WiFi_SSID::get_Device_WiFi_SSID_Fields(int ssidIndex) if (jsonObj) { - cJSON *state = cJSON_GetObjectItem(jsonObj, "state"); - //ASSIGN TO OP HERE - int res = state->valueint; - switch (res) { + cJSON *state = cJSON_GetObjectItem(jsonObj, "state"); + if (!state || !cJSON_IsNumber(state)) + { + RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] json parse error, \"state\" field missing or not a number\n", __FUNCTION__); + cJSON_Delete(root); + return NOK; + } + int res = state->valueint; + switch (res) { case 0: rc=strcpy_s(status,sizeof(status),"UNINSTALLED"); break; From 0c2e9242df8a854d95950af6063cf0e05e9a5c8f Mon Sep 17 00:00:00 2001 From: Vismal S Kumar Date: Thu, 12 Mar 2026 17:12:11 +0530 Subject: [PATCH 18/18] Update Device_WiFi_SSID.cpp --- src/hostif/profiles/wifi/Device_WiFi_SSID.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp b/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp index e37c4810d..1bcfa97d8 100644 --- a/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp +++ b/src/hostif/profiles/wifi/Device_WiFi_SSID.cpp @@ -351,7 +351,7 @@ int hostIf_WiFi_SSID::get_Device_WiFi_SSID_Fields(int ssidIndex) } else { - RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: getJsonRPCData() failed\n", __FUNCTION__); + RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: Empty response received from NetworkManager.GetAvailableInterfaces JSON-RPC request\n", __FUNCTION__); return NOK; } @@ -442,7 +442,7 @@ int hostIf_WiFi_SSID::get_Device_WiFi_SSID_Fields(int ssidIndex) } else { - RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: getJsonRPCData() failed\n", __FUNCTION__); + RDK_LOG (RDK_LOG_ERROR, LOG_TR69HOSTIF, "%s: Empty response received from NetworkManager.GetWifiState JSON-RPC request\n", __FUNCTION__); return NOK; }