Skip to content

RDKEMW-1768 -Fix UT in RRD with Static profile update and Null Check #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: develop
Choose a base branch
from
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
15 changes: 14 additions & 1 deletion src/rrdCommandSanity.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

#include "rrdCommandSanity.h"
#include <ctype.h>

/*
* @function updateBackgroundCmd
Expand Down Expand Up @@ -131,9 +132,21 @@ int isCommandsValid(char *issuecmd,cJSON *sanitylist)
{
subcmd = cJSON_GetArrayItem(sanitylist, i);
checkcmd = cJSON_Print(subcmd); // Print each command from the sanity command array in Json
int len = strlen(checkcmd);
if (len >= 2 && checkcmd[0] == '"' && checkcmd[len - 1] == '"')
{
checkcmd[len - 1] = '\0'; // Remove closing quote
checkcmd++; // Move pointer forward to skip opening quote
len -= 2; // Adjust length after removing quotes
}
// Trim trailing spaces
int j = len - 1;
while (j >= 0 && isspace(checkcmd[j])) {
checkcmd[j] = '\0';
j--;
}
RDK_LOG(RDK_LOG_DEBUG,LOG_REMDEBUG,"[%s:%d]: Checking for \"%s\" string in Issue commands... \n",__FUNCTION__,__LINE__,checkcmd);
sanitystr = strstr(issuecmd,checkcmd);
cJSON_free(checkcmd); // free each command from the sanity command array
if (sanitystr)
{
RDK_LOG(RDK_LOG_ERROR,LOG_REMDEBUG,"[%s:%d]: Found harmful commands: %s, Exiting!!! \n",__FUNCTION__,__LINE__,sanitystr);
Expand Down
9 changes: 9 additions & 0 deletions src/rrdJsonParser.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,15 @@ bool invokeSanityandCommandExec(issueNodeData *issuestructNode, cJSON *jsoncfg,
check = cJSON_GetObjectItem(sanity, "Check");
checkval = cJSON_Print(check); // Print list of sanity commands received
RDK_LOG(RDK_LOG_DEBUG,LOG_REMDEBUG,"[%s:%d]: Reading Sanity Check Commands List: \n%s\n",__FUNCTION__,__LINE__,checkval);
if(checkval ==NULL)
{
RDK_LOG(RDK_LOG_DEBUG,LOG_REMDEBUG,"[%s:%d]: Entering checkval null case : \n",__FUNCTION__,__LINE__);
jsoncfg = readAndParseJSON(RRD_JSON_FILE);
sanity = cJSON_GetObjectItem(jsoncfg, "Sanity");
check = cJSON_GetObjectItem(sanity, "Check");
checkval = cJSON_Print(check); // Print list of sanity commands received
RDK_LOG(RDK_LOG_DEBUG,LOG_REMDEBUG,"[%s:%d]: Reading Sanity Check Commands List: \n%s\n",__FUNCTION__,__LINE__,checkval);
}
cmdlist = cJSON_GetObjectItem(check, "Commands");
cJSON_free(checkval); // free sanity command list
ret = isCommandsValid(issuestdata->command, cmdlist);
Expand Down
Loading