-
Notifications
You must be signed in to change notification settings - Fork 2
Feature/rdk 60236 #186
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?
Feature/rdk 60236 #186
Changes from all commits
cd795e2
a950f13
ba3c8ca
63bc161
c883bd2
9380442
61a9e2c
d672210
65d30d0
93df789
6d37d71
c7588d3
d1345ab
e720479
faacd2a
7daeac3
52539a3
ec1680e
bfb7f1e
e71f82e
72b9562
e6b8690
79f6e64
bd49f43
3a5f988
4587984
5c3f460
3d77c29
b5f062b
f21ad0f
02a0507
f509d0a
d10faa4
5835261
c9dfede
3c19ac2
3084d70
eca3fb2
2cca47b
f44f131
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 | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -29,7 +29,7 @@ static void processIssueTypeInDynamicProfile(data_buf *rbuf, issueNodeData *pIss | |||||||||||||||
| static void processIssueTypeInStaticProfile(data_buf *rbuf, issueNodeData *pIssueNode); | ||||||||||||||||
| static void processIssueTypeInInstalledPackage(data_buf *rbuf, issueNodeData *pIssueNode); | ||||||||||||||||
| static void removeSpecialCharacterfromIssueTypeList(char *str); | ||||||||||||||||
| static int issueTypeSplitter(char *input_str, const char delimeter, char ***args); | ||||||||||||||||
| static int issueTypeSplitter(char *input_str, char *outsuffix, const char delimeter, char ***args); | ||||||||||||||||
| static void freeParsedJson(cJSON *jsonParsed); | ||||||||||||||||
|
Comment on lines
+32
to
33
|
||||||||||||||||
|
|
||||||||||||||||
| /* | ||||||||||||||||
|
|
@@ -62,13 +62,18 @@ void processIssueTypeEvent(data_buf *rbuf) | |||||||||||||||
| char **cmdMap = NULL; | ||||||||||||||||
| int index = 0, count = 0, dataMsgLen = 0; | ||||||||||||||||
| data_buf *cmdBuff = NULL; | ||||||||||||||||
| char suffix[128] = {0}; | ||||||||||||||||
|
|
||||||||||||||||
| RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: ...Entering.. \n", __FUNCTION__, __LINE__); | ||||||||||||||||
| if (NULL != rbuf) | ||||||||||||||||
| { | ||||||||||||||||
| RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: IssueType List [%s]... \n", __FUNCTION__, __LINE__, rbuf->mdata); | ||||||||||||||||
| count = issueTypeSplitter(rbuf->mdata, ',', &cmdMap); | ||||||||||||||||
|
|
||||||||||||||||
| count = issueTypeSplitter(rbuf->mdata, suffix, ',', &cmdMap); | ||||||||||||||||
| if (rbuf->suffix) { | ||||||||||||||||
|
Comment on lines
+71
to
+72
|
||||||||||||||||
| free(rbuf->suffix); | ||||||||||||||||
| } | ||||||||||||||||
| rbuf->suffix = (suffix[0] != '\0') ? strdup(suffix) : NULL; | ||||||||||||||||
|
Comment on lines
+73
to
+75
|
||||||||||||||||
| RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Assigned rbuf->suffix='%s' after issueTypeSplitter\n", __FUNCTION__, __LINE__, rbuf->suffix ? rbuf->suffix : "(null)"); | ||||||||||||||||
| if (count > 0) | ||||||||||||||||
| { | ||||||||||||||||
|
Comment on lines
+74
to
78
|
||||||||||||||||
| RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: IssueType Count [%d]... \n", __FUNCTION__, __LINE__, count); | ||||||||||||||||
|
|
@@ -88,6 +93,13 @@ void processIssueTypeEvent(data_buf *rbuf) | |||||||||||||||
| } | ||||||||||||||||
| cmdBuff->appendMode = rbuf->appendMode; | ||||||||||||||||
| cmdBuff->mdata = (char *)calloc(1, dataMsgLen); | ||||||||||||||||
|
|
||||||||||||||||
| /* Persist suffix */ | ||||||||||||||||
| if (rbuf->suffix) { | ||||||||||||||||
| cmdBuff->suffix = strdup(rbuf->suffix); | ||||||||||||||||
| } else { | ||||||||||||||||
| cmdBuff->suffix = NULL; | ||||||||||||||||
| } | ||||||||||||||||
|
Comment on lines
+97
to
+102
|
||||||||||||||||
| if (cmdBuff->mdata) | ||||||||||||||||
| { | ||||||||||||||||
|
Comment on lines
+100
to
104
|
||||||||||||||||
| strncpy((char *)cmdBuff->mdata, cmdMap[index], dataMsgLen); | ||||||||||||||||
|
|
@@ -97,11 +109,16 @@ void processIssueTypeEvent(data_buf *rbuf) | |||||||||||||||
| { | ||||||||||||||||
| RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Memory Allocation Failed... \n", __FUNCTION__, __LINE__); | ||||||||||||||||
| } | ||||||||||||||||
| if(cmdBuff) | ||||||||||||||||
| { | ||||||||||||||||
| if(cmdBuff) | ||||||||||||||||
| { | ||||||||||||||||
|
||||||||||||||||
| { | |
| { | |
| if (cmdBuff->suffix) | |
| { | |
| free(cmdBuff->suffix); | |
| cmdBuff->suffix = NULL; | |
| } |
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 - Resource leak
Freeing "cmdBuff" without freeing its pointer field "suffix" leaks the storage that "suffix" points to.
High Impact, CWE-404
RESOURCE_LEAK
Copilot
AI
May 1, 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.
The cleanup block frees only cmdBuff but not the newly-added cmdBuff->suffix. This leaks memory for each processed issue type (and also leaks on the cmdBuff->mdata allocation failure path). Free cmdBuff->suffix (if set) before freeing the struct.
Copilot
AI
May 1, 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.
cmdBuff->suffix is newly allocated but cmdBuff is released via free(cmdBuff) rather than RRD_data_buff_deAlloc, and checkIssueNodeInfo does not free buff->suffix. This leaks cmdBuff->suffix on the success path. Prefer calling RRD_data_buff_deAlloc(cmdBuff) here, or explicitly free cmdBuff->suffix (and any other owned fields) before freeing the struct.
Copilot
AI
May 1, 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.
There are existing unit tests for issueTypeSplitter in src/unittest/rrdUnitTestRunner.cpp that call the old signature (issueTypeSplitter(str, ',', &args)). This signature change adds outsuffix, so the unit-test build will break unless those tests are updated, and new assertions should be added to cover the suffix-splitting behavior.
Copilot
AI
May 1, 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.
issueTypeSplitter writes to outsuffix with strncpy(outsuffix, suffix, 128) but the function doesn't take outsuffix's length. This makes the helper unsafe to reuse and also doesn't guarantee NUL-termination for smaller buffers. Pass an outsuffix_len parameter and bound/terminate the copy accordingly (and validate outsuffix != NULL).
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,6 +46,49 @@ void removeSpecialChar(char *str) | |
| } | ||
| } | ||
|
|
||
| /* | ||
| * @function split_issue_type | ||
| * @brief Utility to split base and suffix from issue type string. | ||
| * Example: Input: Device.DeviceTime_Search-b6877385-9463-45fc-b19d-a24d77fd0790 | ||
| * Output: base = Device.DeviceTime, suffix = _Search-b6877385-9463-45fc-b19d-a24d77fd0790 | ||
| * @param const char *input - The input string to split. | ||
| * @param char *base - Buffer to store the base part (before the first underscore). | ||
| * @param size_t base_len - Size of the base buffer. | ||
| * @param char *suffix - Buffer to store the suffix part (from the first underscore onwards). | ||
| * @param size_t suffix_len - Size of the suffix buffer. | ||
| * @return void | ||
| */ | ||
|
|
||
| void split_issue_type(const char *input, char *base, size_t base_len, char *suffix, size_t suffix_len) { | ||
| if (!input || !base || !suffix) return; | ||
|
Abhinavpv28 marked this conversation as resolved.
Abhinavpv28 marked this conversation as resolved.
|
||
|
|
||
| if (base_len == 0 || suffix_len == 0) { | ||
| if (base && base_len > 0) { | ||
| base[0] = '\0'; | ||
| } | ||
| if (suffix && suffix_len > 0) { | ||
| suffix[0] = '\0'; | ||
| } | ||
| return; | ||
| } | ||
| RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: split_issue_type called with input='%s'\n", __FUNCTION__, __LINE__, input); | ||
| const char *underscore = strchr(input, '_'); | ||
| if (underscore) { | ||
|
Comment on lines
+65
to
+76
|
||
| size_t b_len = underscore - input; | ||
| if (b_len >= base_len) b_len = base_len - 1; | ||
|
Comment on lines
+54
to
+78
|
||
| strncpy(base, input, b_len); | ||
| base[b_len] = '\0'; | ||
| strncpy(suffix, underscore, suffix_len - 1); | ||
| suffix[suffix_len - 1] = '\0'; | ||
| } else { | ||
|
Comment on lines
+79
to
+83
|
||
| strncpy(base, input, base_len - 1); | ||
| base[base_len - 1] = '\0'; | ||
| suffix[0] = '\0'; | ||
|
Comment on lines
+62
to
+86
|
||
| } | ||
| RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: split_issue_type result: base='%s', suffix='%s'\n", __FUNCTION__, __LINE__, base, suffix); | ||
| } | ||
|
|
||
|
|
||
| /* | ||
| * @function getParamcount | ||
| * @brief Calculates the total number of nodes (elements) in the input string, excluding delimiters. | ||
|
|
@@ -515,7 +558,11 @@ void checkIssueNodeInfo(issueNodeData *issuestructNode, cJSON *jsoncfg, data_buf | |
| { | ||
| RDK_LOG(RDK_LOG_ERROR,LOG_REMDEBUG,"[%s:%d]: Memory allocation failed for rfcbuf\n",__FUNCTION__,__LINE__); | ||
| free(buff->mdata); // free rfc data | ||
| buff->mdata = NULL; | ||
| free(buff->jsonPath); // free rrd path info | ||
| buff->jsonPath = NULL; | ||
| free(buff->suffix); // free suffix | ||
| buff->suffix = NULL; | ||
| return; | ||
| } | ||
|
|
||
|
|
@@ -535,7 +582,11 @@ void checkIssueNodeInfo(issueNodeData *issuestructNode, cJSON *jsoncfg, data_buf | |
| RDK_LOG(RDK_LOG_ERROR,LOG_REMDEBUG,"[%s:%d]: %s Directory creation failed!!!\n",__FUNCTION__,__LINE__,outdir); | ||
| free(rfcbuf); // free duplicated rfc data | ||
| free(buff->mdata); // free rfc data | ||
| buff->mdata = NULL; | ||
| free(buff->jsonPath); // free rrd path info | ||
| buff->jsonPath = NULL; | ||
| free(buff->suffix); // free suffix | ||
| buff->suffix = NULL; | ||
| return; | ||
| } | ||
| else | ||
|
|
@@ -576,7 +627,14 @@ void checkIssueNodeInfo(issueNodeData *issuestructNode, cJSON *jsoncfg, data_buf | |
| else | ||
| { | ||
| RDK_LOG(RDK_LOG_DEBUG,LOG_REMDEBUG,"[%s:%d]: Continue uploading Debug Report for %s from %s... \n",__FUNCTION__,__LINE__,buff->mdata,outdir); | ||
| status = uploadDebugoutput(outdir,buff->mdata); | ||
| // Use the persisted suffix from buff for upload | ||
| char tarName[512] = {0}; | ||
| if (buff->suffix && buff->suffix[0] != '\0') { | ||
| snprintf(tarName, sizeof(tarName), "%s%s", buff->mdata, buff->suffix); | ||
| } else { | ||
| snprintf(tarName, sizeof(tarName), "%s", buff->mdata); | ||
| } | ||
| status = uploadDebugoutput(outdir, tarName); | ||
|
Comment on lines
+633
to
+637
|
||
| if(status != 0) | ||
|
Comment on lines
+631
to
638
|
||
| { | ||
| RDK_LOG(RDK_LOG_ERROR,LOG_REMDEBUG,"[%s:%d]: RRD Upload Script Execution Failed!!! status:%d\n",__FUNCTION__,__LINE__,status); | ||
|
|
@@ -588,14 +646,22 @@ void checkIssueNodeInfo(issueNodeData *issuestructNode, cJSON *jsoncfg, data_buf | |
| } | ||
| free(rfcbuf); // free duplicated rfc data | ||
| free(buff->mdata); // free rfc data | ||
| buff->mdata = NULL; | ||
| free(buff->jsonPath); // free rrd path info | ||
| buff->jsonPath = NULL; | ||
| free(buff->suffix); // free suffix | ||
| buff->suffix = NULL; | ||
| } | ||
| else | ||
| { | ||
| RDK_LOG(RDK_LOG_ERROR,LOG_REMDEBUG,"[%s:%d]: No Command excuted as RRD Failed to change directory:%s\n",__FUNCTION__,__LINE__,outdir); | ||
| free(rfcbuf); // free duplicated rfc data | ||
| free(buff->mdata); // free rfc data | ||
| buff->mdata = NULL; | ||
| free(buff->jsonPath); // free rrd path info | ||
| buff->jsonPath = NULL; | ||
| free(buff->suffix); // free suffix | ||
| buff->suffix = NULL; | ||
| } | ||
| } | ||
| } | ||
|
|
||
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.
issueTypeSplitteris astaticfunction that is included and unit-tested viasrc/unittest/rrdUnitTestRunner.cpp(it directly includesrrdEventProcess.c). This signature change adds theoutsuffixparameter, so the existing unit tests will no longer compile until they are updated to pass the extra argument.