Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ CcspAliasMgrFindMakeNode
if ( !pChildNode )
{
AnscTcFree((ANSC_HANDLE)pNsTokenChain);
pNsTokenChain = NULL; /*CID: 154673 fix for Use after free*/

CcspTraceError(("TR-069 alias mapper - failed to allocate child node %s\n", Name));

break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -884,11 +884,8 @@ DslhWmpdoMpaSetParameterValues
while (g_isBusy && count > 0)
{
CcspTraceWarning(("<< %s, It's g_isBusy busy try again in 250ms>>\n",__FUNCTION__));
/*CID: 257711 fix for Waiting while holding a lock*/
AnscReleaseTsLock(&pMyObject->AccessTsLock);
usleep(250000);
count --;
AnscAcquireTsLock(&pMyObject->AccessTsLock);
}
pthread_mutex_lock(&NotifyMutex);

Expand All @@ -900,15 +897,10 @@ DslhWmpdoMpaSetParameterValues
*ppInvalidParameterName = AnscCloneString(pParameterValueArray[i].Name);
returnStatus = CCSP_ERR_INVALID_PARAMETER_VALUE;
pthread_mutex_unlock(&NotifyMutex);
/*CID: 72271 fix for Resource leak*/
if(vcSig.newValue)
AnscFreeMemory((char*)vcSig.newValue);
if(vcSig.oldValue)
AnscFreeMemory((char*)vcSig.oldValue);
break;
}
/*sensitive information like keyPassphrase should not print*/
if(_ansc_strstr(str,"KeyPassphrase") == NULL) /*CID: 66607 fix for Array compared against 0*/
if((str != NULL) && (_ansc_strstr(str,"KeyPassphrase") == NULL))
{
CcspTraceWarning(("<< %s sending Notification str %s >>\n",__FUNCTION__,str));
}
Expand Down Expand Up @@ -960,14 +952,9 @@ DslhWmpdoMpaSetParameterValues
{
/* init the variable and object record arrays; */
pMyObject->InitObjVarArray(hThisObject);
}
/*CID: 272608 fix for Dereference after null check*/
pObjRecordArray = (PDSLH_OBJ_RECORD_OBJECT* )pMyObject->hObjRecordArray;
pVarRecordArray = (PDSLH_VAR_RECORD_OBJECT* )pMyObject->hVarRecordArray;

if ( !pVarRecordArray || !pObjRecordArray )
{
goto EXIT2;
pObjRecordArray = (PDSLH_OBJ_RECORD_OBJECT* )pMyObject->hObjRecordArray;
pVarRecordArray = (PDSLH_VAR_RECORD_OBJECT* )pMyObject->hVarRecordArray;
}

ulParameterCount =
Expand Down Expand Up @@ -1001,14 +988,8 @@ DslhWmpdoMpaSetParameterValues
for ( i = 0; i < ulObjectCount; i++ )
{
pObjRecord = (PDSLH_OBJ_RECORD_OBJECT)pObjRecordArray[i];
/*CID: 272608 fix for Dereference after null check*/
if ( !pObjRecord )
{
/*
* Impossible, no need for error handling...
*/
}
else

if ( pObjRecord != NULL)
{
if ( !pObjRecord->VerifyChanges((ANSC_HANDLE)pObjRecord, &pFaultParamName) )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ PoamIrepFoGetFolderByIndex
if(rc < EOK)
{
ERR_CHK(rc);
AnscFreeMemory(pName); /*CID: 186266 fix for Resource leak*/
return NULL;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,9 @@ Bmc2ReqcoDoTransfer

if ( param_list )
{
/*CID: 164053 and 186730 Resource leak- Free the memory in SlapVhoCloneParamList */
/*CID: 164053 Resource leak- Free the memory in SlapVhoCloneParamList */
/* SlapVhoCloneParamList allocates memory that is stored into dst_param_list*/
SlapCloneParamList(param_list, pAsyncJob->ParamList, TRUE);
SlapCloneParamList(param_list, pAsyncJob->ParamList);
}

AnscSpawnTask
Expand Down Expand Up @@ -337,9 +337,9 @@ Bmc2ReqcoDoExecute

if ( param_list )
{
/*CID: 164052 and 186730 Resource leak - Free the ptr in SlapVhoCloneParamList */
/*CID: 164052 Resource leak - Free the ptr in SlapVhoCloneParamList */
/* SlapVhoCloneParamList allocates memory that is stored into dst_param_list*/
SlapCloneParamList(param_list, pAsyncJob->ParamList, TRUE);
SlapCloneParamList(param_list, pAsyncJob->ParamList);
}

AnscSpawnTask
Expand Down
5 changes: 2 additions & 3 deletions source/cosa/package/slap/include/slap_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -712,11 +712,10 @@ SLAP_PARAMETER_LIST, *PSLAP_PARAMETER_LIST;
SlapVhoInitParamList((ANSC_HANDLE)NULL, tbi_list); \
}

/*CID: 164052 and 186730 Resource leak - Free the ptr in SlapVhoCloneParamList */
#define SlapCloneParamList(src_list, dst_list, free_dst_list) \
#define SlapCloneParamList(src_list, dst_list) \
{ \
ANSC_HANDLE dst_param_list = (ANSC_HANDLE)dst_list; \
SlapVhoCloneParamList((ANSC_HANDLE)NULL, src_list, &dst_param_list, free_dst_list); \
SlapVhoCloneParamList((ANSC_HANDLE)NULL, src_list, &dst_param_list); \
}

#define SlapCleanParamList(tbc_list) \
Expand Down
3 changes: 1 addition & 2 deletions source/cosa/package/slap/include/slap_vho_exported_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,7 @@ SlapVhoCloneParamList
(
ANSC_HANDLE hThisObject,
ANSC_HANDLE src_param_list,
ANSC_HANDLE* dst_param_list,
BOOL free_dst_list
ANSC_HANDLE* dst_param_list
);

void
Expand Down
3 changes: 1 addition & 2 deletions source/cosa/package/slap/include/slap_vho_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,7 @@ typedef void
(
ANSC_HANDLE hThisObject,
ANSC_HANDLE src_param_list,
ANSC_HANDLE* dst_param_list,
BOOL free_dst_list
ANSC_HANDLE* dst_param_list
);

typedef void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,14 @@ SetParamValueHelper
if ( CCSP_SUCCESS != ret || 1 != size )
{
free_parameterValStruct_t (MsgBusHandle, size, ppParamVal);
goto cleanup; /*CID: 71382 and 66253 fix for Resource leak*/
return returnStatus;
}

if ( strValStruct[0].type != ppParamVal[0]->type) //datatype miss match
{
//printf("Exit on Type Miss Match ..\n");
free_parameterValStruct_t (MsgBusHandle, size, ppParamVal);
goto cleanup; /*CID: 71382 and 66253 fix for Resource leak*/
return returnStatus;
}

free_parameterValStruct_t (MsgBusHandle, size, ppParamVal);
Expand Down Expand Up @@ -281,20 +281,6 @@ SetParamValueHelper

returnStatus = ANSC_STATUS_SUCCESS;
return returnStatus;

/*CID: 71382 and 66253 fix for Resource leak*/
cleanup:
if (dst_componentid)
{
AnscFreeMemory(dst_componentid);
}

if (dst_dbus_path)
{
AnscFreeMemory(dst_dbus_path);
}

return returnStatus;
}

/**********************************************************************
Expand Down Expand Up @@ -761,17 +747,6 @@ SlapDslhParamtoGetParamValue

}
free_parameterValStruct_t(MsgBusHandle, size, ppParamVal);
/*CID: 64172 and 71299 fix for Resource leak*/
if (dst_componentid)
{
AnscFreeMemory(dst_componentid);
}

if (dst_dbus_path)
{
AnscFreeMemory(dst_dbus_path);
}

return pRetSlapVal;
}

Expand Down Expand Up @@ -936,16 +911,6 @@ SlapDslhParamtoGetParamTypeAndValue
*ppValue = AnscCloneString((ppParamVal[0]->parameterValue));
}
free_parameterValStruct_t(MsgBusHandle, size, ppParamVal);
/*CID: 64681 and 66136 fix for Resource leak*/
if (dst_componentid)
{
AnscFreeMemory(dst_componentid);
}

if (dst_dbus_path)
{
AnscFreeMemory(dst_dbus_path);
}
}


Expand Down Expand Up @@ -1596,13 +1561,7 @@ SlapDslhParamtoGetParamInfo

if ( CCSP_SUCCESS != ret || 1 > size)
{
free_componentStruct_t(MsgBusHandle, size, ppComponents);
/*CID: 61556 fix for Resource leak*/
if (pParamName != NULL)
{
AnscFreeMemory(pParamName);
}

free_componentStruct_t(MsgBusHandle, size, ppComponents);
if (CCSP_CR_ERR_UNSUPPORTED_NAMESPACE == ret || CCSP_CR_ERR_INVALID_PARAM == ret )
return 1;
else
Expand Down Expand Up @@ -2068,11 +2027,7 @@ SlapDslhParamtoGetParamInfoShort
pParamName = AnscCloneString("Device.");
}

/*CID: 66694 fix for Resource leak*/
if (pParamName != NULL)
{
uParentLength = AnscSizeOfString(pParamName);
}
uParentLength = AnscSizeOfString(pParamName);

ret = CcspBaseIf_discComponentSupportingNamespace
(
Expand All @@ -2086,13 +2041,7 @@ SlapDslhParamtoGetParamInfoShort

if ( CCSP_SUCCESS != ret || 1 > size)
{
free_componentStruct_t(MsgBusHandle, size, ppComponents);
/*CID: 66694 fix for Resource leak*/
if (pParamName != NULL)
{
AnscFreeMemory(pParamName);
}

free_componentStruct_t(MsgBusHandle, size, ppComponents);
if (CCSP_CR_ERR_UNSUPPORTED_NAMESPACE == ret || CCSP_CR_ERR_INVALID_PARAM == ret )
return 1;
else
Expand Down Expand Up @@ -2706,7 +2655,7 @@ SlapDslhParamtoAddObject
{
AnscFreeMemory(NumArray);
}
goto cleanup; /*CID: 69263 fix for Resource leak*/
return ANSC_STATUS_FAILURE;
}

InstanceNumber = NumArray[Nums - 1] + 1;
Expand All @@ -2723,24 +2672,10 @@ SlapDslhParamtoAddObject

if(ret != CCSP_SUCCESS )
{
goto cleanup; /*CID: 69263 fix for Resource leak*/
return ANSC_STATUS_FAILURE;
}

return InstanceNumber;

/*CID: 69263 fix for Resource leak*/
cleanup:
if (dst_componentid)
{
AnscFreeMemory(dst_componentid);
}

if (dst_dbus_path)
{
AnscFreeMemory(dst_dbus_path);
}

return ANSC_STATUS_FAILURE;
}


Expand Down Expand Up @@ -2834,18 +2769,7 @@ SlapDslhParamtoDelObject
pObjName
);

/*CID: 59079 and 59659 fix for Resource leak*/
if (dst_componentid)
{
AnscFreeMemory(dst_componentid);
}

if (dst_dbus_path)
{
AnscFreeMemory(dst_dbus_path);
}

if(ret != CCSP_SUCCESS )
if(ret != CCSP_SUCCESS )
{
return ANSC_STATUS_FAILURE;
}
Expand Down Expand Up @@ -3139,33 +3063,19 @@ SlapDslhParamtoIsParameterReadOnly
if ( CCSP_SUCCESS != ret || size != 1 )
{
free_parameterInfoStruct_t (MsgBusHandle, size, ppParamInfos);
goto cleanup; /*CID: 66124 fix for Resource leak*/
return bReadOnly;
}

if ( TRUE == ppParamInfos[0]->writable)
{
free_parameterInfoStruct_t (MsgBusHandle, size, ppParamInfos);
goto cleanup; /*CID: 66124 fix for Resource leak*/
return bReadOnly;
}

free_parameterInfoStruct_t (MsgBusHandle, size, ppParamInfos);

bReadOnly = TRUE;
return bReadOnly;

/*CID: 66124 fix for Resource leak*/
cleanup:
if (dst_componentid)
{
AnscFreeMemory(dst_componentid);
}

if (dst_dbus_path)
{
AnscFreeMemory(dst_dbus_path);
}

return bReadOnly;
}


Expand Down
14 changes: 4 additions & 10 deletions source/cosa/utilities/bsp_eng/bspeng_archive_co_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -1276,28 +1276,22 @@ BspTemplateArchiveSaveToFile
int size;
ULONG ulSize;

while (total < pArchive->ContentLen)
while (total <= pArchive->ContentLen)
{
/*CID: 279849 fix for Out-of-bounds access*/
const char *suffix = ((total > 0) && (total % 40 == 0)) ? "\n" : "";
size =
sprintf_s
(
buf, sizeof(buf), "%d,%s",
pArchive->pStorage[total],
suffix
(total % 40 == 0 && total != 0)?"\n":""
);
if(size < 0)
{
ERR_CHK(size);
}
total++;
ulSize = (ULONG)size; /*CID: 559862 fix for Overflowed constant*/
/*CID: 340787 fix for Improper use of negative value*/
if (ulSize > 0)
{
AnscWriteFile(hFile, buf, &ulSize);
}
ulSize = size;
AnscWriteFile(hFile, buf, &ulSize);
}
}
else
Expand Down
Loading