Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions rfcMgr/rfc_xconf_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "rfc_xconf_handler.h"
#include "rfc_common.h"
#include <errno.h>
#include "rfcapi.h"
#include "rfc_mgr_json.h"
#include "mtlsUtils.h"
Expand Down Expand Up @@ -1297,7 +1298,7 @@ void RuntimeFeatureControlProcessor::clearDB(void)

set_RFCProperty(name, ClearDB, clearValue);
set_RFCProperty(name, BootstrapClearDB, clearValue);
set_RFCProperty(name, ConfigChangeTimeKey, ConfigChangeTime);
set_RFCProperty(name, std::move(ConfigChangeTimeKey), ConfigChangeTime);

RDK_LOG(RDK_LOG_INFO, LOG_RFCMGR, "[%s][%d] Clearing DB Value: %s\n", __FUNCTION__,__LINE__,ClearDB.c_str());
RDK_LOG(RDK_LOG_INFO, LOG_RFCMGR, "[%s][%d] Bootstrap Clearing DB Value: %s\n", __FUNCTION__,__LINE__,BootstrapClearDB.c_str());
Expand Down Expand Up @@ -1466,15 +1467,15 @@ void RuntimeFeatureControlProcessor::updateHashAndTimeInDB(char *curlHeaderResp)
// Output the value
RDK_LOG(RDK_LOG_INFO, LOG_RFCMGR, "configSetHash value: %s\n", configSetHashValue.c_str());

updateHashInDB(configSetHashValue);
updateHashInDB(std::move(configSetHashValue));
} else {
RDK_LOG(RDK_LOG_ERROR, LOG_RFCMGR, "configSetHash not found in httpHeader!");
}


std::time_t timestamp = std::time(nullptr); // Get current timestamp
std::string timestampString = std::to_string(timestamp);
updateTimeInDB(timestampString);
updateTimeInDB(std::move(timestampString));

std::fstream fs;
fs.open(RFC_SYNC_DONE, std::ios::out);
Expand Down Expand Up @@ -1507,9 +1508,9 @@ bool RuntimeFeatureControlProcessor::IsDirectBlocked()
else
{
RDK_LOG(RDK_LOG_INFO, LOG_RFCMGR,"[%s][%d] RFC: Last direct failed blocking has expired, removing %s, allowing direct \n", __FUNCTION__, __LINE__, DIRECT_BLOCK_FILENAME);
if (remove(DIRECT_BLOCK_FILENAME) != 0)
if (remove(DIRECT_BLOCK_FILENAME) != 0 && errno != ENOENT)
{
RDK_LOG(RDK_LOG_ERROR, LOG_RFCMGR,"[%s][%d]Failed to remove file %s\n", __FUNCTION__, __LINE__, DIRECT_BLOCK_FILENAME);
RDK_LOG(RDK_LOG_ERROR, LOG_RFCMGR,"[%s][%d]Failed to remove file %s, errno=%d\n", __FUNCTION__, __LINE__, DIRECT_BLOCK_FILENAME,errno);
}
}
}
Expand Down Expand Up @@ -1988,7 +1989,18 @@ int RuntimeFeatureControlProcessor::DownloadRuntimeFeatutres(DownloadData *pDwnL
}
if(file_dwnl.hashData != nullptr)
{
if(file_dwnl.hashData->hashvalue != nullptr)
{
free(file_dwnl.hashData->hashvalue);
file_dwnl.hashData->hashvalue = nullptr;
}
if(file_dwnl.hashData->hashtime != nullptr)
{
free(file_dwnl.hashData->hashtime);
file_dwnl.hashData->hashtime = nullptr;
}
free(file_dwnl.hashData);
file_dwnl.hashData = nullptr;
Comment on lines 1990 to +2003
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

hashParam and its inner allocations are only freed via file_dwnl.hashData on the main success path, but there are several earlier return paths in this function (e.g., MTLS cert failures, cert selector init failure, or the case where pDwnLoc->pvOut/pHeaderDwnLoc->pvOut are null) that exit without hitting this cleanup, leaking both the hashParam_t struct and any strdup-allocated strings. Consider centralizing cleanup (e.g., a single exit path with a cleanup block or a small RAII helper) so that hashParam->hashvalue, hashParam->hashtime, and hashParam are released consistently on all return paths, including error conditions and the !pDwnLoc->pvOut || !pHeaderDwnLoc->pvOut case.

Copilot uses AI. Check for mistakes.
}

if (_url_validation_in_progress)
Expand Down Expand Up @@ -2021,7 +2033,10 @@ int RuntimeFeatureControlProcessor::DownloadRuntimeFeatutres(DownloadData *pDwnL
case 83:
case 90:
case 91:
NotifyTelemetry2ErrorCode(curl_ret_code);
NotifyTelemetry2ErrorCode(curl_ret_code);
break;
default:
break;
}

if((curl_ret_code == 0) && (httpCode == 404))
Expand Down Expand Up @@ -2480,7 +2495,7 @@ void RuntimeFeatureControlProcessor::processXconfResponseConfigDataPart(JSON *fe
}
std::string data = "TR181: " + newKey + " " + newValue;

paramList.push_back(data);
paramList.push_back(std::move(data));
}

updateTR181File(TR181_FILE_LIST, paramList);
Expand Down Expand Up @@ -2887,7 +2902,7 @@ int RuntimeFeatureControlProcessor::ProcessXconfUrl(const char *XconfUrl)
std::string FQDN = _xconf_server_url;
_xconf_server_url = std::string(XconfUrl) + "/featureControl/getSettings";
std::stringstream url = CreateXconfHTTPUrl();
_xconf_server_url = FQDN;
_xconf_server_url = std::move(FQDN);

DownloadData DwnLoc, HeaderDwnLoc;
InitDownloadData(&DwnLoc);
Expand Down
Loading