-
Notifications
You must be signed in to change notification settings - Fork 2
RDK-60307 [RRD] RDK Coverity Defect Resolution for Device Management #175
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -114,11 +114,11 @@ void processIssueTypeEvent(data_buf *rbuf) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if( cmdMap) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if( cmdMap) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| free(cmdMap); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cmdMap = NULL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cmdMap = NULL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -164,31 +164,126 @@ static void processIssueType(data_buf *rbuf) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (staticprofiledata == NULL) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: Static Command Info not found for IssueType!!! \n", __FUNCTION__, __LINE__); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Free dynamicprofiledata since we can't proceed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (dynamicprofiledata != NULL) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (dynamicprofiledata->rfcvalue != NULL) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| free(dynamicprofiledata->rfcvalue); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (dynamicprofiledata->command != NULL) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| free(dynamicprofiledata->command); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| free(dynamicprofiledata); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: Read complete for Static Profile: RFCValue: %s, Command: %s, Timeout: %d... \n", __FUNCTION__, __LINE__, staticprofiledata->rfcvalue, staticprofiledata->command, staticprofiledata->timeout); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| //Remove the double quotes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| size_t staticstrlen = strlen(staticprofiledata->command); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| size_t dynamicstrlen = strlen(dynamicprofiledata->command); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (staticstrlen > 0 && staticprofiledata->command[staticstrlen - 1] == '"') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| staticprofiledata->command[staticstrlen - 1] = '\0'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Check if commands are NULL before using them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (dynamicprofiledata->command == NULL || staticprofiledata->command == NULL) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: Command is NULL in dynamic or static profile... \n", __FUNCTION__, __LINE__); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Free dynamicprofiledata | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (dynamicprofiledata != NULL) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (dynamicprofiledata->rfcvalue != NULL) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| free(dynamicprofiledata->rfcvalue); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (dynamicprofiledata->command != NULL) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| free(dynamicprofiledata->command); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| free(dynamicprofiledata); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Free staticprofiledata | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (staticprofiledata != NULL) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (staticprofiledata->rfcvalue != NULL) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| free(staticprofiledata->rfcvalue); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (staticprofiledata->command != NULL) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Coverity issue no longer present as of: undefined Show issueCoverity Issue - Dereference before null checkNull-checking "staticprofiledata->command" suggests that it may be null, but it has already been dereferenced on all paths leading to the check. Medium Impact, CWE-476 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| free(staticprofiledata->command); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| free(staticprofiledata); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (dynamicprofiledata->command[0] == '"') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dynamicprofiledata->command[0] = COMMAND_DELIM; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| //Remove the double quotes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| size_t staticstrlen = strlen(staticprofiledata->command); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| size_t dynamicstrlen = strlen(dynamicprofiledata->command); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (staticstrlen > 0 && staticprofiledata->command[staticstrlen - 1] == '"') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| staticprofiledata->command[staticstrlen - 1] = '\0'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| staticstrlen--; // Update length after removing trailing quote | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (dynamicprofiledata->command[0] == '"') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dynamicprofiledata->command[0] = COMMAND_DELIM; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Static Profile Commands: %s, Dynamic Profile Commands: %s\n", __FUNCTION__, __LINE__, staticprofiledata->command, dynamicprofiledata->command); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| size_t appendstrlen = (staticstrlen + dynamicstrlen + 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| char *appendcommandstr = (char *)realloc(staticprofiledata->command, appendstrlen); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (appendcommandstr == NULL) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: Memory Allocation Failed... \n", __FUNCTION__, __LINE__); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Free staticprofiledata on realloc failure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (staticprofiledata != NULL) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (staticprofiledata->rfcvalue != NULL) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| free(staticprofiledata->rfcvalue); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (staticprofiledata->command != NULL) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| free(staticprofiledata->command); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| free(staticprofiledata); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| staticprofiledata = NULL; // Set to NULL to prevent double-free | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Free dynamicprofiledata on realloc failure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (dynamicprofiledata != NULL) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (dynamicprofiledata->rfcvalue != NULL) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| free(dynamicprofiledata->rfcvalue); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (dynamicprofiledata->command != NULL) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| free(dynamicprofiledata->command); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| free(dynamicprofiledata); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| dynamicprofiledata = NULL; // Set to NULL to prevent double-free | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| strcat(appendcommandstr, dynamicprofiledata->command); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| staticprofiledata->command = appendcommandstr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: Updated command after append from dynamic and static profile: %s \n", __FUNCTION__, __LINE__, staticprofiledata->command); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RDK_LOG(RDK_LOG_DEBUG,LOG_REMDEBUG,"[%s:%d]: Executing Commands in Runtime Service... \n",__FUNCTION__,__LINE__); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| checkIssueNodeInfo(pIssueNode, NULL, rbuf, false, staticprofiledata); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // NOTE: staticprofiledata is freed by executeCommands() via checkIssueNodeInfo() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Do NOT free staticprofiledata here to avoid double-free | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+270
to
+271
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // NOTE: staticprofiledata is freed by executeCommands() via checkIssueNodeInfo() | |
| // Do NOT free staticprofiledata here to avoid double-free | |
| /* In append mode, checkIssueNodeInfo() frees pIssueNode->Node/subNode, | |
| * but not the issueNodeData container itself. Free it here to avoid | |
| * leaking the allocation. | |
| */ | |
| if (pIssueNode != NULL) | |
| { | |
| free(pIssueNode); | |
| pIssueNode = NULL; | |
| } | |
| /* Ownership of staticprofiledata: | |
| * - In non-GTEST builds, staticprofiledata is freed by executeCommands() | |
| * (invoked via checkIssueNodeInfo()). | |
| * - In GTEST builds, executeCommands() does not free it, so clean it up here. | |
| */ | |
| #ifdef GTEST_ENABLE | |
| if (staticprofiledata != NULL) | |
| { | |
| if (staticprofiledata->rfcvalue != NULL) | |
| { | |
| free(staticprofiledata->rfcvalue); | |
| } | |
| if (staticprofiledata->command != NULL) | |
| { | |
| free(staticprofiledata->command); | |
| } | |
| free(staticprofiledata); | |
| staticprofiledata = NULL; | |
| } | |
| #endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coverity issue no longer present as of: undefined
Show issue
Coverity Issue - Dereference before null check
Null-checking "dynamicprofiledata->command" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
Medium Impact, CWE-476
REVERSE_INULL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed as we go for dynamic download
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -96,7 +96,22 @@ char * readJsonFile(char *jsonfile) | |||||||||||||||||||
| } | ||||||||||||||||||||
| fseek(fp, 0, SEEK_SET); | ||||||||||||||||||||
| jsonfile_content = (char *) malloc(sizeof(char) * (ch_count + 1)); | ||||||||||||||||||||
| fread(jsonfile_content, 1, ch_count,fp); | ||||||||||||||||||||
| if (jsonfile_content == NULL) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| RDK_LOG(RDK_LOG_ERROR,LOG_REMDEBUG,"[%s:%d]: Memory allocation failed for json file %s \n",__FUNCTION__,__LINE__,jsonfile); | ||||||||||||||||||||
| fclose(fp); | ||||||||||||||||||||
| return NULL; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| size_t bytes_read = fread(jsonfile_content, 1, ch_count, fp); | ||||||||||||||||||||
| if (bytes_read != (size_t)ch_count) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| RDK_LOG(RDK_LOG_ERROR,LOG_REMDEBUG,"[%s:%d]: Failed to read json file %s. Expected %d bytes, read %zu bytes \n",__FUNCTION__,__LINE__,jsonfile,ch_count,bytes_read); | ||||||||||||||||||||
| free(jsonfile_content); | ||||||||||||||||||||
| fclose(fp); | ||||||||||||||||||||
| return NULL; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| jsonfile_content[ch_count] ='\0'; | ||||||||||||||||||||
| fclose(fp); | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
@@ -312,6 +327,10 @@ issueData * getIssueCommandInfo(issueNodeData *issuestructNode, cJSON *jsoncfg, | |||||||||||||||||||
| tmpCommand = cJSON_Print(elem); | ||||||||||||||||||||
| if(tmpCommand) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| if(issuestdata->command != NULL) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| free(issuestdata->command); // Free previous command before overwriting | ||||||||||||||||||||
| } | ||||||||||||||||||||
| issuestdata->command = strdup(tmpCommand); // print command info from json file | ||||||||||||||||||||
| cJSON_free(tmpCommand); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
@@ -322,6 +341,7 @@ issueData * getIssueCommandInfo(issueNodeData *issuestructNode, cJSON *jsoncfg, | |||||||||||||||||||
| { | ||||||||||||||||||||
| RDK_LOG(RDK_LOG_ERROR,LOG_REMDEBUG,"[%s:%d]: No Commands found, exiting.. \n",__FUNCTION__,__LINE__); | ||||||||||||||||||||
| free(issuestdata); | ||||||||||||||||||||
| return NULL; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else | ||||||||||||||||||||
| { | ||||||||||||||||||||
|
|
@@ -337,6 +357,7 @@ issueData * getIssueCommandInfo(issueNodeData *issuestructNode, cJSON *jsoncfg, | |||||||||||||||||||
| RDK_LOG(RDK_LOG_ERROR,LOG_REMDEBUG,"[%s:%d]: Aborting Command execution due to Harmful commands!!!\n",__FUNCTION__,__LINE__); | ||||||||||||||||||||
| free(issuestdata->command); | ||||||||||||||||||||
| free(issuestdata); | ||||||||||||||||||||
| return NULL; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else | ||||||||||||||||||||
| { | ||||||||||||||||||||
|
|
@@ -415,6 +436,10 @@ bool invokeSanityandCommandExec(issueNodeData *issuestructNode, cJSON *jsoncfg, | |||||||||||||||||||
| tmpCommand = cJSON_Print(elem); | ||||||||||||||||||||
| if(tmpCommand) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| if(issuestdata->command != NULL) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| free(issuestdata->command); // Free previous command before overwriting | ||||||||||||||||||||
| } | ||||||||||||||||||||
| issuestdata->command = strdup(tmpCommand); // print command info from json file | ||||||||||||||||||||
| cJSON_free(tmpCommand); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
@@ -486,6 +511,14 @@ void checkIssueNodeInfo(issueNodeData *issuestructNode, cJSON *jsoncfg, data_buf | |||||||||||||||||||
| struct tm *ltime; | ||||||||||||||||||||
| rfcbuf = strdup(buff->mdata); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if (rfcbuf == NULL) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| RDK_LOG(RDK_LOG_ERROR,LOG_REMDEBUG,"[%s:%d]: Memory allocation failed for rfcbuf\n",__FUNCTION__,__LINE__); | ||||||||||||||||||||
| free(buff->mdata); // free rfc data | ||||||||||||||||||||
| free(buff->jsonPath); // free rrd path info | ||||||||||||||||||||
|
||||||||||||||||||||
| free(buff->jsonPath); // free rrd path info | |
| free(buff->jsonPath); // free rrd path info | |
| if (issuestructNode != NULL) | |
| { | |
| free(issuestructNode->Node); | |
| issuestructNode->Node = NULL; | |
| free(issuestructNode->subNode); | |
| issuestructNode->subNode = NULL; | |
| } |
Copilot
AI
Feb 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
processAllDebugCommand no longer frees rfcbuf (to avoid a double-free from checkIssueNodeInfo), but the function’s doc comment still doesn’t state the ownership contract, and existing unit tests pass a strdup’d buffer without freeing it. Please update the function/header documentation to explicitly say the caller owns rfcbuf (and ensure tests/callers free it accordingly).
| // Note: rfcbuf is owned by caller and will be freed there | |
| // Note: rfcbuf is owned by the caller; this function must not free it. | |
| // The caller is responsible for freeing rfcbuf after this function returns. |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -40,7 +40,9 @@ static cacheData *cacheDataNode = NULL; | |||||||||
| void initCache(void) | ||||||||||
| { | ||||||||||
| pthread_mutex_init(&rrdCacheMut, NULL); | ||||||||||
| pthread_mutex_lock(&rrdCacheMut); | ||||||||||
| cacheDataNode = NULL; | ||||||||||
| pthread_mutex_unlock(&rrdCacheMut); | ||||||||||
|
Comment on lines
+43
to
+45
|
||||||||||
| pthread_mutex_lock(&rrdCacheMut); | |
| cacheDataNode = NULL; | |
| pthread_mutex_unlock(&rrdCacheMut); | |
| cacheDataNode = NULL; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3892,7 +3892,7 @@ TEST_F(GetIssueCommandInfoTest, ReturnsValidStruct) { | |
|
|
||
| char buf[] = "rfcvalue123"; | ||
| issueData* result = getIssueCommandInfo(&node, root, buf); | ||
| ASSERT_NE(result, nullptr); | ||
| ASSERT_EQ(result, nullptr); | ||
|
|
||
|
Comment on lines
3893
to
3896
|
||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
processIssueTypeEvent()allocates/receivesdata_buf* rbufvia the message queue, but the function never freesrbuf(and doesn’t freerbuf->mdata/rbuf->jsonPatheither). SinceRRDMsgDeliver()passes pointers (not copies), this is a real heap leak per message and likely the root cause behind the Coverityleaked_storagesuppressions. Please add a single well-defined deallocation point (e.g., callRRD_data_buff_deAlloc(rbuf)once the message has been fully processed, possibly inRRDEventThreadFuncafter each switch case).