Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
32 changes: 31 additions & 1 deletion source/app/libpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,15 @@ static void connect_parodus()
WalPrint("libparodus_shutdown retval %d\n", retval);
}
}
/* CID-71358 CID-55326 Resource leak fix */
if (parodus_url != NULL)
{
free(parodus_url);
}
if (client_url != NULL)
{
free(client_url);
}
}

//set global conn status and to awake waiting getter threads
Expand Down Expand Up @@ -194,6 +203,9 @@ static void parodus_receive()
memset(res_headers, 0, (sizeof(headers_t) + sizeof( char * ) * (wrp_msg->u.req.headers->count)));
}
else {
/* CID-59824 Resource leak fix */
free(res_wrp_msg);
res_wrp_msg = NULL;
WalError("Memory not allocated for response headers\n");
return;
}
Expand Down Expand Up @@ -257,7 +269,14 @@ static void parodus_receive()
}
getCurrentTime(endPtr);
WalInfo("Elapsed time : %ld ms\n", timeValDiff(startPtr, endPtr));
wrp_free_struct (res_wrp_msg);
wrp_free_struct (res_wrp_msg);
/* CID-334851 Resource leak fix */
if(res_headers != NULL)
{
WalInfo("Deallocating memory for response headers\n");
free(res_headers);
res_headers = NULL;
}
}
wrp_free_struct (wrp_msg);
}
Expand All @@ -280,6 +299,17 @@ static void parodus_receive()
WalPrint("set cloud-status value as %s\n", status);
}
}
/* CID-273897 Resource leak fix */
if (sourceService != NULL)
{
free(sourceService);
sourceService = NULL;
}
if (sourceApplication != NULL)
{
free(sourceApplication);
sourceApplication = NULL;
}
wrp_free_struct (wrp_msg);
}
}
Expand Down
7 changes: 6 additions & 1 deletion source/broadband/cosa_webpa_dml.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,12 @@ X_RDK_Webpa_SetParamStringValue
PCOSA_DML_WEBPA_CONFIG pWebpaCfg = (PCOSA_DML_WEBPA_CONFIG)pWebpa->pWebpaCfg;

WalPrint("<========= Start of X_RDK_Webpa_SetParamStringValue ========>\n");
WalInfo("Received data ParamName %s,data length: %d bytes\n",ParamName, strlen(pString));
/* CID-255476 Dereference before null check fix */
if (pString != NULL) {
WalInfo("Received data ParamName %s,data length: %d bytes\n",ParamName, strlen(pString));
} else {
WalInfo("Received data ParamName %s, pString is NULL\n",ParamName);
}

if( AnscEqualString(ParamName, "ConnectedClientNotify", TRUE))
{
Expand Down
4 changes: 4 additions & 0 deletions source/broadband/ssp_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ if ( bRunAsDaemon )
{
return WDMP_FAILURE;
}
/* CID-61738 Logically dead code - bRunAsDaemon is always true */
#if 0
else
{
while ( cmdChar != 'q' )
Expand All @@ -144,6 +146,7 @@ if ( bRunAsDaemon )
}
}


err = Cdm_Term();
if (err != CCSP_SUCCESS)
{
Expand All @@ -153,6 +156,7 @@ if ( bRunAsDaemon )

ssp_cancel();
return WDMP_SUCCESS;
#endif
}

/*----------------------------------------------------------------------------*/
Expand Down
5 changes: 4 additions & 1 deletion source/broadband/ssp_messagebus_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ ANSC_STATUS ssp_Mbi_MessageBusEngage(char * component_id,char * config_file,char
if ( ! component_id || ! path )
{
CcspTraceError((" !!! ssp_Mbi_MessageBusEngage: component_id or path is NULL !!!\n"));
/* CID-53104 Return failure if component_id or path is NULL */
return ANSC_STATUS_FAILURE;
}

/* Connect to message bus */
Expand All @@ -42,7 +44,8 @@ ANSC_STATUS ssp_Mbi_MessageBusEngage(char * component_id,char * config_file,char
return returnStatus;
}

CcspTraceInfo(("INFO: bus_handle: 0x%8x \n", bus_handle));
/* CID 268716 Invalid printf format specifier fix*/
CcspTraceInfo(("INFO: bus_handle: %p \n", bus_handle));
g_MessageBusHandle_Irep = bus_handle;
AnscCopyString(g_SubSysPrefix_Irep, g_Subsystem);

Expand Down
27 changes: 21 additions & 6 deletions source/broadband/webpa_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,7 @@ static void getObjectName(char *str, char *objectName, int objectLevel)

static void waitUntilSystemReady()
{
int ret = 0;
if(checkIfSystemReady())
{
WalInfo("Checked CR - System is ready, proceed with component caching\n");
Expand All @@ -1107,8 +1108,13 @@ static void waitUntilSystemReady()
}
else
{
CcspBaseIf_Register_Event(bus_handle, NULL, "systemReadySignal");

ret = CcspBaseIf_Register_Event(bus_handle, NULL, "systemReadySignal");
/* CID-65122 Unchecked return value fix */
if (CCSP_SUCCESS != ret)
{
WalError("Failed to register for systemReadySignal event, ret=%d\n", ret);
return;
}
CcspBaseIf_SetCallback2
(
bus_handle,
Expand Down Expand Up @@ -1474,15 +1480,24 @@ WDMP_STATUS createForceSyncJsonSchema(char *value, char *transactionId, char** s
}

char *forcesyncVal = strdup(value);
char *forcesynctransID = strdup(transactionId);
cJSON *jsonresponse = NULL;
/*CID-565213 CID-565214 Resource leak fix*/
if(forcesyncVal == NULL)
{
WalError("Memory allocation failed in createForceSyncJsonSchema for forcesyncVal\n");
return WDMP_FAILURE;
}

if (forcesyncVal == NULL || forcesynctransID == NULL)
char *forcesynctransID = strdup(transactionId);
/*CID-565213 CID-565214 Resource leak fix*/
if(forcesynctransID == NULL)
{
WalError("Memory allocation failed in createForceSyncJsonSchema\n");
WalError("Memory allocation failed in createForceSyncJsonSchema for forcesynctransID\n");
WAL_FREE(forcesyncVal);
return WDMP_FAILURE;
}

cJSON *jsonresponse = NULL;

WalPrint("forcesyncVal %s forcesynctransID %s\n", forcesyncVal, forcesynctransID);
jsonresponse = cJSON_CreateObject();

Expand Down
19 changes: 17 additions & 2 deletions source/broadband/webpa_notification.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ void initNotifyTask(int status)
{
int err = 0;
pthread_t threadId;
notifyMsgQ = NULL;
int *device_status = (int *) malloc(sizeof(int));
*device_status = status;

Expand Down Expand Up @@ -506,6 +505,9 @@ void ccspWebPaValueChangedCB(parameterSigStruct_t* val, int size, void* user_dat
WalInfo("set g_syncNotifyInProgress, g_checkSyncNotifyRetry to 1\n");

paramNotify= (ParamNotify *) malloc(sizeof(ParamNotify));
/* CID-565403 Uninitialized pointer read Fix */
memset(paramNotify, 0, sizeof(ParamNotify));

if(val->parameterName != NULL)
paramNotify->paramName = strdup(val->parameterName);
if(val->oldValue != NULL)
Expand All @@ -519,7 +521,8 @@ void ccspWebPaValueChangedCB(parameterSigStruct_t* val, int size, void* user_dat
notifyDataPtr->type = PARAM_NOTIFY;
notifyDataPtr->u.notify = paramNotify;

WalInfo("Notification Event from stack: Parameter Name: %s, Data Type: %d, Change Source: %d\n", paramNotify->paramName, paramNotify->type, paramNotify->changeSource);
/* CID-565403 Uninitialized pointer read Fix */
WalInfo("Notification Event from stack: Parameter Name: %s, Data Type: %d, Change Source: %d\n", paramNotify->paramName ? paramNotify->paramName : "NULL", paramNotify->type, paramNotify->changeSource);

(*notifyCbFn)(notifyDataPtr);
}
Expand Down Expand Up @@ -1555,12 +1558,24 @@ void processNotification(NotifyData *notifyData)
if(read_sync_notify_from_file() == 1)
{
WalError("Error while reading param_notify_retry_string from file\n");
/* CID-57566 Resource leak fix */
WAL_FREE(cid);
/* CID-565401 Resource Leak Fix */
WAL_FREE(dest);
cJSON_Delete(notifyPayload);
freeNotifyMessage(notifyData);
return;
}
}
cJSON *parameter = cJSON_Parse(param_notify_string);
if (parameter == NULL) {
WalError("Error in parsing JSON file '%s' content\n",SYNC_NOTIFY_PARAM_BACKUP_FILE);
/* CID-57566 Resource leak fix */
WAL_FREE(cid);
/* CID-565401 Resource Leak Fix */
WAL_FREE(dest);
cJSON_Delete(notifyPayload);
freeNotifyMessage(notifyData);
return;
}
cJSON_AddItemToObject(notifyPayload, "parameter", parameter);
Expand Down
11 changes: 8 additions & 3 deletions source/broadband/webpa_rbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ void webpaRbus_Uninit()
rbusError_t setTraceContext(char* traceContext[])
{
rbusError_t ret = RBUS_ERROR_BUS_ERROR;
if(isRbusInitialized)
/* CID-334852 Function address comparison fix */
if(isRbusInitialized())
{
if(traceContext[0] != NULL && traceContext[1] != NULL) {
if(strlen(traceContext[0]) > 0 && strlen(traceContext[1]) > 0) {
Expand Down Expand Up @@ -83,7 +84,8 @@ rbusError_t getTraceContext(char* traceContext[])
rbusError_t ret = RBUS_ERROR_BUS_ERROR;
char traceParent[512] = {'\0'};
char traceState[512] = {'\0'};
if(isRbusInitialized)
/* CID-334847 Function address comparison fix */
if(isRbusInitialized())
{
ret = rbusHandle_GetTraceContextAsString(rbus_handle, traceParent, sizeof(traceParent), traceState, sizeof(traceState));
if( ret == RBUS_ERROR_SUCCESS) {
Expand All @@ -110,7 +112,8 @@ rbusError_t getTraceContext(char* traceContext[])
rbusError_t clearTraceContext()
{
rbusError_t ret = RBUS_ERROR_BUS_ERROR;
if(isRbusInitialized)
/* CID-334849 Function address comparison fix */
if(isRbusInitialized())
{
ret = rbusHandle_ClearTraceContext(rbus_handle);
if(ret == RBUS_ERROR_SUCCESS) {
Expand All @@ -123,4 +126,6 @@ rbusError_t clearTraceContext()
else {
WalError("Rbus not initialized in clearTraceContext funcion\n");
}
/* CID-334846 missing return statement fix */
return ret;
}
31 changes: 19 additions & 12 deletions source/broadband/webpa_replace.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,6 @@ void replaceTable(char *objectName,TableData * list,unsigned int paramcount,WDMP
WalError("Failed to replace table, hence reverting the changes\n");
addCachedData(objectName,addList,rowCount);
}
for ( cnt = 0 ; cnt < rowCount ; cnt++)
{
for(cnt1 = 0; cnt1 < numParams; cnt1++)
{
WAL_FREE(addList[cnt].names[cnt1]);
WAL_FREE(addList[cnt].values[cnt1]);
}
WAL_FREE(addList[cnt].names);
WAL_FREE(addList[cnt].values);
}
WAL_FREE(addList);
}
}
else
Expand All @@ -130,6 +119,21 @@ void replaceTable(char *objectName,TableData * list,unsigned int paramcount,WDMP
WalError("deleteList is NULL\n");
}
}
/* CID-280996 Resource leak fix */
if(addList != NULL)
{
for ( cnt = 0 ; cnt < rowCount ; cnt++)
{
for(cnt1 = 0; cnt1 < addList[cnt].paramCnt; cnt1++)
{
WAL_FREE(addList[cnt].names[cnt1]);
WAL_FREE(addList[cnt].values[cnt1]);
}
WAL_FREE(addList[cnt].names);
WAL_FREE(addList[cnt].values);
}
WAL_FREE(addList);
}
}
if(isWalStatus == 1)
{
Expand Down Expand Up @@ -301,7 +305,8 @@ static int addNewData(char *objectName,TableData * list,int paramcount)
OnboardLog("Failed to add/update row to %s table, addRet : %d, hence deleting the already added rows\n", objectName, addRet);
for(i= cnt-1; i >= 0; i--)
{
strncpy(paramName,retObject[i],sizeof(paramName));
/* CID-182375 Buffer not null terminated fix */
walStrncpy(paramName,retObject[i],sizeof(paramName));
deleteRowTable(paramName, &delRet);
WalPrint("delRet : %d\n",delRet);
if(delRet != WDMP_SUCCESS)
Expand Down Expand Up @@ -574,6 +579,8 @@ static int getWritableParams(char *paramName, char ***writableParams, int *param
free_componentStruct_t(bus_handle, size, ppComponents);
}
WalPrint("==================== End of getWritableParams ==================\n");
/* CID-320315 Memory leak fix */
WAL_FREE(isRbus);
return ret;
}