Skip to content
Merged
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
49 changes: 40 additions & 9 deletions source/jst_cosa.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
If not stated otherwise in this file or this component's Licenses.txt file the

Check failure on line 2 in source/jst_cosa.c

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID Detected License Issue

Snippet with 'Apache-2.0' file license found (1016 lines) Location: source/jst_cosa.c (link unavailable) Component: rdk/components/generic/jst/rdk/components/generic/jst@rdk-dev-2101 Download: https://code.rdkcentral.com/r/plugins/gitiles/rdk/components/generic/jst/+archive/rdk-dev-2101.tar.gz
following copyright and licenses apply:

Copyright 2018 RDK Management
Expand Down Expand Up @@ -408,34 +408,65 @@
&pInstNumList
);

if (iReturn != CCSP_SUCCESS)
if (iReturn != CCSP_SUCCESS || InstNum == 0 || pInstNumList == NULL)
{
//AnscTraceWarning("Failed on CcspBaseIf_GetNextLevelInstances, error code = %d.\n", iReturn);
//RETURN_STRING("ERROR: Failed on CcspBaseIf_GetNextLevelInstances",1);
if (ppDestComponentName) { free(ppDestComponentName); ppDestComponentName = NULL; }
if (ppDestPath) { free(ppDestPath); ppDestPath = NULL; }
RETURN_STRING("");
}
Comment thread
pavankumar464 marked this conversation as resolved.

for(loop1=0,loop2=0; loop1<(InstNum); loop1++)
/* Build comma-separated instance list safely */
for (loop1 = 0, loop2 = 0; loop1 < InstNum; loop1++)
{
len =sprintf(&format_s[loop2],"%d,", pInstNumList[loop1]);
loop2=loop2+len;
unsigned int prev_loop2 = loop2;

if (loop2 >= (int)(sizeof(format_s) - 1))
{
break;
}

len = snprintf(
&format_s[loop2],
sizeof(format_s) - loop2,
"%u,",
pInstNumList[loop1]);

if (len <= 0)
{
break;
}

if (len >= (int)(sizeof(format_s) - loop2))
{
/* Truncation: discard the partial write so only complete ids remain */
format_s[prev_loop2] = '\0';
loop2 = prev_loop2;
break;
}
Comment thread
pavankumar464 marked this conversation as resolved.

loop2 += len;
}

if (pInstNumList)
{
free(pInstNumList);
}

//Place NULL char at the end of string
if (loop2 >= 1)
if (ppDestComponentName) { free(ppDestComponentName); ppDestComponentName = NULL; }
if (ppDestPath) { free(ppDestPath); ppDestPath = NULL; }

/* Remove trailing comma safely */
if (loop2 > 0 && format_s[loop2 - 1] == ',')
{
format_s[loop2-1]=0;
format_s[loop2 - 1] = '\0';
}
else
{
format_s[0]=0;
CosaPhpExtLog("loop2-1 is less than zero in format_s[]\n");
format_s[loop2] = '\0';
}

RETURN_STRING(format_s);
}

Expand Down
Loading