From cd795e24d4f4da475e17a843c2aadfc6b14b16b9 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Thu, 30 Apr 2026 23:22:42 +0530 Subject: [PATCH 01/40] Refactor issueTypeSplitter to include suffix handling --- src/rrdEventProcess.c | 85 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 73 insertions(+), 12 deletions(-) diff --git a/src/rrdEventProcess.c b/src/rrdEventProcess.c index 5164e7832..ead3b88f3 100644 --- a/src/rrdEventProcess.c +++ b/src/rrdEventProcess.c @@ -17,19 +17,22 @@ * limitations under the License. */ + #include "rrdRunCmdThread.h" #include "rrdJsonParser.h" #include "rrdEventProcess.h" +#include "rrdCommon.h" #define COMMAND_DELIM ';' #define RRD_TMP_DIR "/tmp/" static void processIssueType(data_buf *rbuf); + static void processIssueTypeInDynamicProfile(data_buf *rbuf, issueNodeData *pIssueNode); 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); /* @@ -62,13 +65,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) { + free(rbuf->suffix); + } + rbuf->suffix = (suffix[0] != '\0') ? strdup(suffix) : NULL; + RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: [DEBUG] Assigned rbuf->suffix='%s' after issueTypeSplitter\n", __FUNCTION__, __LINE__, rbuf->suffix ? rbuf->suffix : "(null)"); if (count > 0) { RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: IssueType Count [%d]... \n", __FUNCTION__, __LINE__, count); @@ -86,8 +94,14 @@ void processIssueTypeEvent(data_buf *rbuf) { cmdBuff->jsonPath = rbuf->jsonPath; } - cmdBuff->appendMode = rbuf->appendMode; + cmdBuff->appendMode = rbuf->appendMode; cmdBuff->mdata = (char *)calloc(1, dataMsgLen); + /* Persist suffix */ + if (rbuf->suffix) { + cmdBuff->suffix = strdup(rbuf->suffix); + } else { + cmdBuff->suffix = NULL; + } if (cmdBuff->mdata) { strncpy((char *)cmdBuff->mdata, cmdMap[index], dataMsgLen); @@ -97,11 +111,11 @@ void processIssueTypeEvent(data_buf *rbuf) { RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Memory Allocation Failed... \n", __FUNCTION__, __LINE__); } - if(cmdBuff) - { + if(cmdBuff) + { free(cmdBuff); - cmdBuff = NULL; - } + cmdBuff = NULL; + } } else { @@ -140,13 +154,47 @@ static void processIssueType(data_buf *rbuf) issueData *staticprofiledata = NULL; RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: ...Entering.. \n", __FUNCTION__, __LINE__); - if (rbuf->mdata != NULL) // issue data exits + + if (rbuf->mdata != NULL) // issue data exists { + // Log the incoming mdata before split + RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: [DEBUG] processIssueType: incoming mdata='%s'\n", __FUNCTION__, __LINE__, rbuf->mdata); + RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: [DEBUG] processIssueType: split base='%s', suffix='%s'\n", __FUNCTION__, __LINE__, rbuf->mdata, rbuf->suffix); + + /* + // Split base and suffix + char base[256] = {0}; + char suffix[128] = {0}; + + split_issue_type(rbuf->mdata, base, sizeof(base), suffix, sizeof(suffix)); + + // Log the result of split + RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: [DEBUG] processIssueType: split base='%s', suffix='%s'\n", __FUNCTION__, __LINE__, base, suffix); + + // Overwrite mdata with base for internal processing + strncpy(rbuf->mdata, base, strlen(base)+1); + + // Store suffix for later use (persist in struct) + if (rbuf->suffix) { + free(rbuf->suffix); + } + if (suffix[0] != '\0') { + rbuf->suffix = strdup(suffix); + } else { + rbuf->suffix = NULL; + } + + */ + pIssueNode = (issueNodeData *)malloc(sizeof(issueNodeData)); if(pIssueNode) { getIssueInfo((char *)rbuf->mdata, pIssueNode); // issue data extract RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Extracted Node %s and Sub Node %s \n", __FUNCTION__, __LINE__, pIssueNode->Node, pIssueNode->subNode); + // Utility to split base and suffix from issue type string + // Input: Device.DeviceTime_Search-b6877385-9463-45fc-b19d-a24d77fd0790 + // Output: base = Device.DeviceTime, suffix = _Search-b6877385-9463-45fc-b19d-a24d77fd0790 + if (rbuf->appendMode) { RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Received append request to process static and dynamic profiles... \n", __FUNCTION__, __LINE__); @@ -657,11 +705,25 @@ static void removeSpecialCharacterfromIssueTypeList(char *str) * @param const char delimiter - The character used to split the string. * @param char ***args - Pointer to an array of strings where the tokens will be stored. * @return int - The number of tokens found in the string. - */ -static int issueTypeSplitter(char *input_str, const char delimeter, char ***args) +Splitter */ +static int issueTypeSplitter(char *input_str, char *outsuffix, const char delimeter, char ***args) { int cnt = 1, i = 0; + char *str = input_str; + // Call split_issue_type before removing special characters + /**/ + char base[256] = {0}; + char suffix[128] = {0}; + split_issue_type(str, base, sizeof(base), suffix, sizeof(suffix)); + RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: [INFO] issueTypeSplitter (pre-clean): input='%s', base='%s', suffix='%s'\n", __FUNCTION__, __LINE__, str, base, suffix); + + // Copy base back to str so only the base is processed + strncpy(str, base, sizeof(base)); + str[sizeof(base)-1] = '\0'; + + strncpy(outsuffix, suffix, sizeof(suffix)); + outsuffix[sizeof(suffix)-1] = '\0'; removeSpecialCharacterfromIssueTypeList(str); while (*str == delimeter) @@ -698,4 +760,3 @@ static int issueTypeSplitter(char *input_str, const char delimeter, char ***args return cnt; } - From a950f1361adcec8070f28651af12d062970f9032 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Thu, 30 Apr 2026 23:24:48 +0530 Subject: [PATCH 02/40] Update rrdEventProcess.c --- src/rrdEventProcess.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rrdEventProcess.c b/src/rrdEventProcess.c index ead3b88f3..c53497314 100644 --- a/src/rrdEventProcess.c +++ b/src/rrdEventProcess.c @@ -705,7 +705,7 @@ static void removeSpecialCharacterfromIssueTypeList(char *str) * @param const char delimiter - The character used to split the string. * @param char ***args - Pointer to an array of strings where the tokens will be stored. * @return int - The number of tokens found in the string. -Splitter */ + */ static int issueTypeSplitter(char *input_str, char *outsuffix, const char delimeter, char ***args) { int cnt = 1, i = 0; From ba3c8ca3120089536189d9cf4b5bd253b9f21fd7 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Thu, 30 Apr 2026 23:25:51 +0530 Subject: [PATCH 03/40] Update rrdExecuteScript.c --- src/rrdExecuteScript.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/rrdExecuteScript.c b/src/rrdExecuteScript.c index 0c5c2f116..ead18e500 100644 --- a/src/rrdExecuteScript.c +++ b/src/rrdExecuteScript.c @@ -32,13 +32,22 @@ static void normalizeIssueName(char *str); * @param char *issuename - Issue type from RFC. * @return int - Returns 0 for success and non-zero for failure. */ -int uploadDebugoutput(char *outdir, char *issuename) +// Modified to accept optional suffix for tar name +int uploadDebugoutput(char *outdir, char *issuename, const char *suffix) { int ret = 0; if(outdir != NULL && issuename != NULL) { normalizeIssueName(issuename); + + // Compose tar name with suffix if provided + char tarname[512]; + if (suffix && suffix[0] != '\0') { + snprintf(tarname, sizeof(tarname), "%s%s.tar", issuename, suffix); + } else { + snprintf(tarname, sizeof(tarname), "%s.tar", issuename); + } #ifdef IARMBUS_SUPPORT RDK_LOG(RDK_LOG_INFO,LOG_REMDEBUG,"[%s:%d]: Starting Upload Debug output via API... \n",__FUNCTION__,__LINE__); From 63bc161a036cbd36f817998615a4ead0cf305b0a Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Thu, 30 Apr 2026 23:26:45 +0530 Subject: [PATCH 04/40] Refactor rrdEventProcess.h to rrdExecuteScript.h --- src/rrdEventProcess.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/rrdEventProcess.h b/src/rrdEventProcess.h index c6cb1d651..172523acf 100644 --- a/src/rrdEventProcess.h +++ b/src/rrdEventProcess.h @@ -17,8 +17,8 @@ * limitations under the License. */ -#ifndef _RRDEVENTPROCESS_H_ -#define _RRDEVENTPROCESS_H_ +#ifndef _RRDEXECUTESCRIPT_H_ +#define _RRDEXECUTESCRIPT_H_ #ifdef __cplusplus extern "C" @@ -26,12 +26,10 @@ extern "C" #endif #include "rrdCommon.h" -#include +#include "rrd_upload.h" + +int uploadDebugoutput(char *outdir, char *issuename, const char *suffix); -void processIssueTypeEvent(data_buf *rbuf); -void processWebCfgTypeEvent(data_buf *rbuf); -issueData* processIssueTypeInStaticProfileappend(data_buf *rbuf, issueNodeData *pIssueNode); -issueData* processIssueTypeInDynamicProfileappend(data_buf *rbuf, issueNodeData *pIssueNode); #ifdef __cplusplus } #endif From c883bd2db328d998b5322eeb30e7876ff5ade138 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Thu, 30 Apr 2026 23:28:10 +0530 Subject: [PATCH 05/40] Update rrdExecuteScript.h --- src/rrdExecuteScript.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rrdExecuteScript.h b/src/rrdExecuteScript.h index 02705448d..dbd2ae2f9 100644 --- a/src/rrdExecuteScript.h +++ b/src/rrdExecuteScript.h @@ -28,7 +28,7 @@ extern "C" #include "rrdCommon.h" #include "rrd_upload.h" -int uploadDebugoutput(char *outdir, char *issuename); +int uploadDebugoutput(char *outdir, char *issuename, const char *suffix); #ifdef __cplusplus } From 9380442d1e780480d86a310ed6409ffa497b5830 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Thu, 30 Apr 2026 23:28:31 +0530 Subject: [PATCH 06/40] Update rrdExecuteScript.h --- src/rrdExecuteScript.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/rrdExecuteScript.h b/src/rrdExecuteScript.h index dbd2ae2f9..d90af7ea1 100644 --- a/src/rrdExecuteScript.h +++ b/src/rrdExecuteScript.h @@ -17,8 +17,8 @@ * limitations under the License. */ -#ifndef _RRDEXECUTESCRIPT_H_ -#define _RRDEXECUTESCRIPT_H_ +#ifndef _RRDEVENTPROCESS_H_ +#define _RRDEVENTPROCESS_H_ #ifdef __cplusplus extern "C" @@ -26,10 +26,12 @@ extern "C" #endif #include "rrdCommon.h" -#include "rrd_upload.h" - -int uploadDebugoutput(char *outdir, char *issuename, const char *suffix); +#include +void processIssueTypeEvent(data_buf *rbuf); +void processWebCfgTypeEvent(data_buf *rbuf); +issueData* processIssueTypeInStaticProfileappend(data_buf *rbuf, issueNodeData *pIssueNode); +issueData* processIssueTypeInDynamicProfileappend(data_buf *rbuf, issueNodeData *pIssueNode); #ifdef __cplusplus } #endif From 61a9e2c6f6f86c02f47258e6a0f8d03de7b21a59 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Thu, 30 Apr 2026 23:30:29 +0530 Subject: [PATCH 07/40] Update rrdEventProcess.h --- src/rrdEventProcess.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/rrdEventProcess.h b/src/rrdEventProcess.h index 172523acf..c6cb1d651 100644 --- a/src/rrdEventProcess.h +++ b/src/rrdEventProcess.h @@ -17,8 +17,8 @@ * limitations under the License. */ -#ifndef _RRDEXECUTESCRIPT_H_ -#define _RRDEXECUTESCRIPT_H_ +#ifndef _RRDEVENTPROCESS_H_ +#define _RRDEVENTPROCESS_H_ #ifdef __cplusplus extern "C" @@ -26,10 +26,12 @@ extern "C" #endif #include "rrdCommon.h" -#include "rrd_upload.h" - -int uploadDebugoutput(char *outdir, char *issuename, const char *suffix); +#include +void processIssueTypeEvent(data_buf *rbuf); +void processWebCfgTypeEvent(data_buf *rbuf); +issueData* processIssueTypeInStaticProfileappend(data_buf *rbuf, issueNodeData *pIssueNode); +issueData* processIssueTypeInDynamicProfileappend(data_buf *rbuf, issueNodeData *pIssueNode); #ifdef __cplusplus } #endif From d6722108b364a2b76acef151bdfda42ade3d6f22 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Thu, 30 Apr 2026 23:31:33 +0530 Subject: [PATCH 08/40] Update rrdExecuteScript.h --- src/rrdExecuteScript.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/rrdExecuteScript.h b/src/rrdExecuteScript.h index d90af7ea1..dbd2ae2f9 100644 --- a/src/rrdExecuteScript.h +++ b/src/rrdExecuteScript.h @@ -17,8 +17,8 @@ * limitations under the License. */ -#ifndef _RRDEVENTPROCESS_H_ -#define _RRDEVENTPROCESS_H_ +#ifndef _RRDEXECUTESCRIPT_H_ +#define _RRDEXECUTESCRIPT_H_ #ifdef __cplusplus extern "C" @@ -26,12 +26,10 @@ extern "C" #endif #include "rrdCommon.h" -#include +#include "rrd_upload.h" + +int uploadDebugoutput(char *outdir, char *issuename, const char *suffix); -void processIssueTypeEvent(data_buf *rbuf); -void processWebCfgTypeEvent(data_buf *rbuf); -issueData* processIssueTypeInStaticProfileappend(data_buf *rbuf, issueNodeData *pIssueNode); -issueData* processIssueTypeInDynamicProfileappend(data_buf *rbuf, issueNodeData *pIssueNode); #ifdef __cplusplus } #endif From 65d30d012148621d4568001447e7f1ccaa462f7d Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Thu, 30 Apr 2026 23:32:08 +0530 Subject: [PATCH 09/40] Update rrdJsonParser.c --- src/rrdJsonParser.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/src/rrdJsonParser.c b/src/rrdJsonParser.c index e06d93ac2..f743a86ab 100644 --- a/src/rrdJsonParser.c +++ b/src/rrdJsonParser.c @@ -1,3 +1,4 @@ +#include "rrdCommon.h" /* * If not stated otherwise in this file or this component's LICENSE file the * following copyright and licenses apply: @@ -46,6 +47,29 @@ void removeSpecialChar(char *str) } } +// Utility to split base and suffix from issue type string +// Input: Device.DeviceTime_Search-b6877385-9463-45fc-b19d-a24d77fd0790 +// Output: base = Device.DeviceTime, suffix = _Search-b6877385-9463-45fc-b19d-a24d77fd0790 +void split_issue_type(const char *input, char *base, size_t base_len, char *suffix, size_t suffix_len) { + if (!input || !base || !suffix) return; + RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: [INFO] split_issue_type called with input='%s'\n", __FUNCTION__, __LINE__, input); + const char *underscore = strchr(input, '_'); + if (underscore) { + size_t b_len = underscore - input; + if (b_len >= base_len) b_len = base_len - 1; + strncpy(base, input, b_len); + base[b_len] = '\0'; + strncpy(suffix, underscore, suffix_len - 1); + suffix[suffix_len - 1] = '\0'; + } else { + strncpy(base, input, base_len - 1); + base[base_len - 1] = '\0'; + suffix[0] = '\0'; + } + RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: [INFO] 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. @@ -206,6 +230,7 @@ void getIssueInfo(char *issuestr, issueNodeData *issue) RDK_LOG(RDK_LOG_INFO,LOG_REMDEBUG,"[%s:%d]: Received Main Node= %s, SubNode= %s\n",__FUNCTION__,__LINE__,issue->Node,issue->subNode); } + /* * @function findIssueInParsedJSON * @brief Finds if an issue category and issue type is present in the parsed JSON. @@ -576,7 +601,20 @@ 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.tar.gz", buff->mdata, buff->suffix); + } else { + snprintf(tarName, sizeof(tarName), "%s.tar.gz", buff->mdata); + } + RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Tar file name for upload: '%s'\n", __FUNCTION__, __LINE__, tarName); + RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: [INFO] Tar file name for upload: '%s'\n", __FUNCTION__, __LINE__, tarName); + RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: [INFO] Directory for upload: '%s'\n", __FUNCTION__, __LINE__, outdir); + RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: [INFO] Original issue string: '%s'\n", __FUNCTION__, __LINE__, buff->mdata); + RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: [INFO] Suffix used for upload: '%s'\n", __FUNCTION__, __LINE__, buff->suffix ? buff->suffix : ""); + RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: [INFO] Tar file name for upload: '%s'\n", __FUNCTION__, __LINE__, tarName); + status = uploadDebugoutput(outdir, tarName, buff->suffix ? buff->suffix : ""); if(status != 0) { RDK_LOG(RDK_LOG_ERROR,LOG_REMDEBUG,"[%s:%d]: RRD Upload Script Execution Failed!!! status:%d\n",__FUNCTION__,__LINE__,status); From 93df789ce56c59326bc7b57ad566e5272347c58c Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Thu, 30 Apr 2026 23:32:43 +0530 Subject: [PATCH 10/40] Update rrdJsonParser.h --- src/rrdJsonParser.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/rrdJsonParser.h b/src/rrdJsonParser.h index 299436101..87c4a2622 100644 --- a/src/rrdJsonParser.h +++ b/src/rrdJsonParser.h @@ -47,6 +47,8 @@ issueData* getIssueCommandInfo(issueNodeData *issuestructNode, cJSON *jsoncfg,ch bool processAllDebugCommand(cJSON *jsoncfg, issueNodeData *issuestructNode, char *rfcbuf); bool processAllDeepSleepAwkMetricsCommands(cJSON *jsoncfg, issueNodeData *issuestructNode, char *rfcbuf); +void split_issue_type(const char *input, char *base, size_t base_len, char *suffix, size_t suffix_len); + #ifdef __cplusplus } #endif From 6d37d7142bb20390b5fa5dbda47ccaa9895fab3d Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Thu, 30 Apr 2026 23:33:39 +0530 Subject: [PATCH 11/40] Update rrdInterface.c --- src/rrdInterface.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/rrdInterface.c b/src/rrdInterface.c index b69dd8936..30291cd84 100644 --- a/src/rrdInterface.c +++ b/src/rrdInterface.c @@ -275,6 +275,7 @@ void RRD_data_buff_init(data_buf *sbuf, message_type_et sndtype, deepsleep_event sbuf->inDynamic = false; sbuf->appendMode = false; sbuf->dsEvent = deepSleepEvent; + sbuf->suffix = NULL; } /*Function: RRD_data_buff_deAlloc @@ -295,6 +296,10 @@ void RRD_data_buff_deAlloc(data_buf *sbuf) { free(sbuf->jsonPath); } + if (sbuf->suffix) + { + free(sbuf->suffix); + } free(sbuf); } } From c7588d3772e36dcbc3c9e8c9b67df741dca5104b Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Thu, 30 Apr 2026 23:35:41 +0530 Subject: [PATCH 12/40] Update rrdCommon.h --- src/rrdCommon.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/rrdCommon.h b/src/rrdCommon.h index b91ff6f7b..34a6a232c 100644 --- a/src/rrdCommon.h +++ b/src/rrdCommon.h @@ -68,6 +68,7 @@ extern "C" #define BUF_LEN_128 128 #define APPEND_SUFFIX "_apnd" + /* Enum for Messages Queue*/ typedef enum { RRD_EVENT_MSG_DEFAULT = 0, @@ -97,6 +98,7 @@ typedef struct mbuffer { bool inDynamic; bool appendMode; deepsleep_event_et dsEvent; + char *suffix; // Holds the suffix split from issue type string, if any } data_buf; /*Structure for Message Header*/ From d1345abee7f535dea2efc81effded6050132c0c8 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Thu, 30 Apr 2026 23:37:59 +0530 Subject: [PATCH 13/40] Update rrdEventProcess.c --- src/rrdEventProcess.c | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/src/rrdEventProcess.c b/src/rrdEventProcess.c index c53497314..f52b6bb14 100644 --- a/src/rrdEventProcess.c +++ b/src/rrdEventProcess.c @@ -157,35 +157,6 @@ static void processIssueType(data_buf *rbuf) if (rbuf->mdata != NULL) // issue data exists { - // Log the incoming mdata before split - RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: [DEBUG] processIssueType: incoming mdata='%s'\n", __FUNCTION__, __LINE__, rbuf->mdata); - RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: [DEBUG] processIssueType: split base='%s', suffix='%s'\n", __FUNCTION__, __LINE__, rbuf->mdata, rbuf->suffix); - - /* - // Split base and suffix - char base[256] = {0}; - char suffix[128] = {0}; - - split_issue_type(rbuf->mdata, base, sizeof(base), suffix, sizeof(suffix)); - - // Log the result of split - RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: [DEBUG] processIssueType: split base='%s', suffix='%s'\n", __FUNCTION__, __LINE__, base, suffix); - - // Overwrite mdata with base for internal processing - strncpy(rbuf->mdata, base, strlen(base)+1); - - // Store suffix for later use (persist in struct) - if (rbuf->suffix) { - free(rbuf->suffix); - } - if (suffix[0] != '\0') { - rbuf->suffix = strdup(suffix); - } else { - rbuf->suffix = NULL; - } - - */ - pIssueNode = (issueNodeData *)malloc(sizeof(issueNodeData)); if(pIssueNode) { From e72047967fc334e0e1a65e27a2b8d919c23bff19 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 1 May 2026 08:05:24 +0530 Subject: [PATCH 14/40] Update rrdEventProcess.c --- src/rrdEventProcess.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rrdEventProcess.c b/src/rrdEventProcess.c index f52b6bb14..027ddbcf4 100644 --- a/src/rrdEventProcess.c +++ b/src/rrdEventProcess.c @@ -690,7 +690,7 @@ static int issueTypeSplitter(char *input_str, char *outsuffix, const char delime RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: [INFO] issueTypeSplitter (pre-clean): input='%s', base='%s', suffix='%s'\n", __FUNCTION__, __LINE__, str, base, suffix); // Copy base back to str so only the base is processed - strncpy(str, base, sizeof(base)); + strncpy(str, base, sizeof(str)); str[sizeof(base)-1] = '\0'; strncpy(outsuffix, suffix, sizeof(suffix)); From faacd2a5183f1b93dbafa5661a240d8a9d74e177 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 1 May 2026 08:07:11 +0530 Subject: [PATCH 15/40] Update rrdEventProcess.c --- src/rrdEventProcess.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/rrdEventProcess.c b/src/rrdEventProcess.c index 027ddbcf4..7ff0ceb72 100644 --- a/src/rrdEventProcess.c +++ b/src/rrdEventProcess.c @@ -17,7 +17,6 @@ * limitations under the License. */ - #include "rrdRunCmdThread.h" #include "rrdJsonParser.h" #include "rrdEventProcess.h" @@ -27,7 +26,6 @@ #define RRD_TMP_DIR "/tmp/" static void processIssueType(data_buf *rbuf); - static void processIssueTypeInDynamicProfile(data_buf *rbuf, issueNodeData *pIssueNode); static void processIssueTypeInStaticProfile(data_buf *rbuf, issueNodeData *pIssueNode); static void processIssueTypeInInstalledPackage(data_buf *rbuf, issueNodeData *pIssueNode); From 7daeac36bfefef4c089447aabc48f35f24bdc24b Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 1 May 2026 08:09:01 +0530 Subject: [PATCH 16/40] Update rrdEventProcess.c --- src/rrdEventProcess.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/rrdEventProcess.c b/src/rrdEventProcess.c index 7ff0ceb72..4bc68f245 100644 --- a/src/rrdEventProcess.c +++ b/src/rrdEventProcess.c @@ -160,10 +160,6 @@ static void processIssueType(data_buf *rbuf) { getIssueInfo((char *)rbuf->mdata, pIssueNode); // issue data extract RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Extracted Node %s and Sub Node %s \n", __FUNCTION__, __LINE__, pIssueNode->Node, pIssueNode->subNode); - // Utility to split base and suffix from issue type string - // Input: Device.DeviceTime_Search-b6877385-9463-45fc-b19d-a24d77fd0790 - // Output: base = Device.DeviceTime, suffix = _Search-b6877385-9463-45fc-b19d-a24d77fd0790 - if (rbuf->appendMode) { RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Received append request to process static and dynamic profiles... \n", __FUNCTION__, __LINE__); @@ -680,8 +676,6 @@ static int issueTypeSplitter(char *input_str, char *outsuffix, const char delime int cnt = 1, i = 0; char *str = input_str; - // Call split_issue_type before removing special characters - /**/ char base[256] = {0}; char suffix[128] = {0}; split_issue_type(str, base, sizeof(base), suffix, sizeof(suffix)); From 52539a373d2d947634d134923d56500218d07f9c Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 1 May 2026 08:10:59 +0530 Subject: [PATCH 17/40] Fix indentation for appendMode assignment --- src/rrdEventProcess.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rrdEventProcess.c b/src/rrdEventProcess.c index 4bc68f245..37d6e52b6 100644 --- a/src/rrdEventProcess.c +++ b/src/rrdEventProcess.c @@ -92,7 +92,7 @@ void processIssueTypeEvent(data_buf *rbuf) { cmdBuff->jsonPath = rbuf->jsonPath; } - cmdBuff->appendMode = rbuf->appendMode; + cmdBuff->appendMode = rbuf->appendMode; cmdBuff->mdata = (char *)calloc(1, dataMsgLen); /* Persist suffix */ if (rbuf->suffix) { From ec1680e4f696951bc5461df768fb4a21b1647613 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 1 May 2026 08:15:00 +0530 Subject: [PATCH 18/40] Update rrdCommon.h --- src/rrdCommon.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/rrdCommon.h b/src/rrdCommon.h index 34a6a232c..8f5544b77 100644 --- a/src/rrdCommon.h +++ b/src/rrdCommon.h @@ -68,7 +68,6 @@ extern "C" #define BUF_LEN_128 128 #define APPEND_SUFFIX "_apnd" - /* Enum for Messages Queue*/ typedef enum { RRD_EVENT_MSG_DEFAULT = 0, From bfb7f1e3b8d1bccde45f50523a63c0747603f6b3 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 1 May 2026 08:15:56 +0530 Subject: [PATCH 19/40] Fix appendMode assignment in rrdEventProcess.c --- src/rrdEventProcess.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rrdEventProcess.c b/src/rrdEventProcess.c index 37d6e52b6..a4b090737 100644 --- a/src/rrdEventProcess.c +++ b/src/rrdEventProcess.c @@ -92,7 +92,7 @@ void processIssueTypeEvent(data_buf *rbuf) { cmdBuff->jsonPath = rbuf->jsonPath; } - cmdBuff->appendMode = rbuf->appendMode; + cmdBuff->appendMode = rbuf->appendMode; cmdBuff->mdata = (char *)calloc(1, dataMsgLen); /* Persist suffix */ if (rbuf->suffix) { From e71f82e268de66f581e6af08fafea81250ffa248 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 1 May 2026 08:18:00 +0530 Subject: [PATCH 20/40] Update rrdEventProcess.c --- src/rrdEventProcess.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rrdEventProcess.c b/src/rrdEventProcess.c index a4b090737..b947de796 100644 --- a/src/rrdEventProcess.c +++ b/src/rrdEventProcess.c @@ -92,8 +92,9 @@ void processIssueTypeEvent(data_buf *rbuf) { cmdBuff->jsonPath = rbuf->jsonPath; } - cmdBuff->appendMode = rbuf->appendMode; + cmdBuff->appendMode = rbuf->appendMode; cmdBuff->mdata = (char *)calloc(1, dataMsgLen); + /* Persist suffix */ if (rbuf->suffix) { cmdBuff->suffix = strdup(rbuf->suffix); From 72b956265491d51fee2d67b18e3176d05a703b6c Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 1 May 2026 08:23:28 +0530 Subject: [PATCH 21/40] Update rrdJsonParser.c --- src/rrdJsonParser.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/rrdJsonParser.c b/src/rrdJsonParser.c index f743a86ab..c3bad26c6 100644 --- a/src/rrdJsonParser.c +++ b/src/rrdJsonParser.c @@ -230,7 +230,6 @@ void getIssueInfo(char *issuestr, issueNodeData *issue) RDK_LOG(RDK_LOG_INFO,LOG_REMDEBUG,"[%s:%d]: Received Main Node= %s, SubNode= %s\n",__FUNCTION__,__LINE__,issue->Node,issue->subNode); } - /* * @function findIssueInParsedJSON * @brief Finds if an issue category and issue type is present in the parsed JSON. From e6b869087e7db4ef08754f068a0fcf14cde773a2 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 1 May 2026 11:32:32 +0530 Subject: [PATCH 22/40] Update rrdEventProcess.c --- src/rrdEventProcess.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/rrdEventProcess.c b/src/rrdEventProcess.c index b947de796..912eecd6f 100644 --- a/src/rrdEventProcess.c +++ b/src/rrdEventProcess.c @@ -677,17 +677,15 @@ static int issueTypeSplitter(char *input_str, char *outsuffix, const char delime int cnt = 1, i = 0; char *str = input_str; - char base[256] = {0}; + char base[128] = {0}; char suffix[128] = {0}; split_issue_type(str, base, sizeof(base), suffix, sizeof(suffix)); RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: [INFO] issueTypeSplitter (pre-clean): input='%s', base='%s', suffix='%s'\n", __FUNCTION__, __LINE__, str, base, suffix); // Copy base back to str so only the base is processed - strncpy(str, base, sizeof(str)); - str[sizeof(base)-1] = '\0'; - - strncpy(outsuffix, suffix, sizeof(suffix)); - outsuffix[sizeof(suffix)-1] = '\0'; + strncpy(str, base, 128); + + strncpy(outsuffix, suffix, 128); removeSpecialCharacterfromIssueTypeList(str); while (*str == delimeter) From 79f6e647ce7de45121061c88733dfa527347b8e7 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 1 May 2026 11:52:30 +0530 Subject: [PATCH 23/40] Update rrdExecuteScript.h --- src/rrdExecuteScript.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rrdExecuteScript.h b/src/rrdExecuteScript.h index dbd2ae2f9..02705448d 100644 --- a/src/rrdExecuteScript.h +++ b/src/rrdExecuteScript.h @@ -28,7 +28,7 @@ extern "C" #include "rrdCommon.h" #include "rrd_upload.h" -int uploadDebugoutput(char *outdir, char *issuename, const char *suffix); +int uploadDebugoutput(char *outdir, char *issuename); #ifdef __cplusplus } From bd49f43c7ae5b51fd2a8163a514e5d7d5a8b47c3 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 1 May 2026 11:54:40 +0530 Subject: [PATCH 24/40] Update rrdExecuteScript.c --- src/rrdExecuteScript.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/rrdExecuteScript.c b/src/rrdExecuteScript.c index ead18e500..f38832768 100644 --- a/src/rrdExecuteScript.c +++ b/src/rrdExecuteScript.c @@ -41,13 +41,6 @@ int uploadDebugoutput(char *outdir, char *issuename, const char *suffix) { normalizeIssueName(issuename); - // Compose tar name with suffix if provided - char tarname[512]; - if (suffix && suffix[0] != '\0') { - snprintf(tarname, sizeof(tarname), "%s%s.tar", issuename, suffix); - } else { - snprintf(tarname, sizeof(tarname), "%s.tar", issuename); - } #ifdef IARMBUS_SUPPORT RDK_LOG(RDK_LOG_INFO,LOG_REMDEBUG,"[%s:%d]: Starting Upload Debug output via API... \n",__FUNCTION__,__LINE__); From 3a5f988878b9c3fc38ee87db438caa02cbf3914d Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 1 May 2026 11:55:17 +0530 Subject: [PATCH 25/40] Update rrdExecuteScript.c --- src/rrdExecuteScript.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rrdExecuteScript.c b/src/rrdExecuteScript.c index f38832768..6dd1c40e9 100644 --- a/src/rrdExecuteScript.c +++ b/src/rrdExecuteScript.c @@ -33,7 +33,7 @@ static void normalizeIssueName(char *str); * @return int - Returns 0 for success and non-zero for failure. */ // Modified to accept optional suffix for tar name -int uploadDebugoutput(char *outdir, char *issuename, const char *suffix) +int uploadDebugoutput(char *outdir, char *issuename) { int ret = 0; From 45879842f081a11c108685c852b670a3f3d03324 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 1 May 2026 11:55:56 +0530 Subject: [PATCH 26/40] Update rrdExecuteScript.c --- src/rrdExecuteScript.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/rrdExecuteScript.c b/src/rrdExecuteScript.c index 6dd1c40e9..0c5c2f116 100644 --- a/src/rrdExecuteScript.c +++ b/src/rrdExecuteScript.c @@ -32,7 +32,6 @@ static void normalizeIssueName(char *str); * @param char *issuename - Issue type from RFC. * @return int - Returns 0 for success and non-zero for failure. */ -// Modified to accept optional suffix for tar name int uploadDebugoutput(char *outdir, char *issuename) { int ret = 0; @@ -40,7 +39,6 @@ int uploadDebugoutput(char *outdir, char *issuename) if(outdir != NULL && issuename != NULL) { normalizeIssueName(issuename); - #ifdef IARMBUS_SUPPORT RDK_LOG(RDK_LOG_INFO,LOG_REMDEBUG,"[%s:%d]: Starting Upload Debug output via API... \n",__FUNCTION__,__LINE__); From 5c3f4600c5e507f46daa6898f0ae04d19ffec3c6 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 1 May 2026 11:57:13 +0530 Subject: [PATCH 27/40] Remove redundant logging from rrdJsonParser --- src/rrdJsonParser.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/rrdJsonParser.c b/src/rrdJsonParser.c index c3bad26c6..eac4b4cd3 100644 --- a/src/rrdJsonParser.c +++ b/src/rrdJsonParser.c @@ -607,13 +607,7 @@ void checkIssueNodeInfo(issueNodeData *issuestructNode, cJSON *jsoncfg, data_buf } else { snprintf(tarName, sizeof(tarName), "%s.tar.gz", buff->mdata); } - RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Tar file name for upload: '%s'\n", __FUNCTION__, __LINE__, tarName); - RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: [INFO] Tar file name for upload: '%s'\n", __FUNCTION__, __LINE__, tarName); - RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: [INFO] Directory for upload: '%s'\n", __FUNCTION__, __LINE__, outdir); - RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: [INFO] Original issue string: '%s'\n", __FUNCTION__, __LINE__, buff->mdata); - RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: [INFO] Suffix used for upload: '%s'\n", __FUNCTION__, __LINE__, buff->suffix ? buff->suffix : ""); - RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: [INFO] Tar file name for upload: '%s'\n", __FUNCTION__, __LINE__, tarName); - status = uploadDebugoutput(outdir, tarName, buff->suffix ? buff->suffix : ""); + status = uploadDebugoutput(outdir, tarName); if(status != 0) { RDK_LOG(RDK_LOG_ERROR,LOG_REMDEBUG,"[%s:%d]: RRD Upload Script Execution Failed!!! status:%d\n",__FUNCTION__,__LINE__,status); From 3d77c290e38832efc8b35d845adc40aded83fbec Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 1 May 2026 12:09:03 +0530 Subject: [PATCH 28/40] Update rrdJsonParser.c --- src/rrdJsonParser.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rrdJsonParser.c b/src/rrdJsonParser.c index eac4b4cd3..0d0306f2e 100644 --- a/src/rrdJsonParser.c +++ b/src/rrdJsonParser.c @@ -603,9 +603,9 @@ void checkIssueNodeInfo(issueNodeData *issuestructNode, cJSON *jsoncfg, data_buf // 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.tar.gz", buff->mdata, buff->suffix); + snprintf(tarName, sizeof(tarName), "%s%s", buff->mdata, buff->suffix); } else { - snprintf(tarName, sizeof(tarName), "%s.tar.gz", buff->mdata); + snprintf(tarName, sizeof(tarName), "%s", buff->mdata); } status = uploadDebugoutput(outdir, tarName); if(status != 0) From b5f062bf380a147dca8e4c4aac9cb5faa659b40e Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 1 May 2026 12:14:06 +0530 Subject: [PATCH 29/40] Update rrdEventProcess.c --- src/rrdEventProcess.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/rrdEventProcess.c b/src/rrdEventProcess.c index 912eecd6f..3574fac18 100644 --- a/src/rrdEventProcess.c +++ b/src/rrdEventProcess.c @@ -20,7 +20,6 @@ #include "rrdRunCmdThread.h" #include "rrdJsonParser.h" #include "rrdEventProcess.h" -#include "rrdCommon.h" #define COMMAND_DELIM ';' #define RRD_TMP_DIR "/tmp/" From f21ad0fd3d819077f5fc7cef6679d974bb3cb8d2 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 1 May 2026 12:14:32 +0530 Subject: [PATCH 30/40] Update rrdJsonParser.c --- src/rrdJsonParser.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/rrdJsonParser.c b/src/rrdJsonParser.c index 0d0306f2e..f141fbbe1 100644 --- a/src/rrdJsonParser.c +++ b/src/rrdJsonParser.c @@ -1,4 +1,3 @@ -#include "rrdCommon.h" /* * If not stated otherwise in this file or this component's LICENSE file the * following copyright and licenses apply: From 02a0507ac158f96ddd4ddca7a6b88c11e8d803c1 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 1 May 2026 12:17:08 +0530 Subject: [PATCH 31/40] Update rrdEventProcess.c --- src/rrdEventProcess.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/rrdEventProcess.c b/src/rrdEventProcess.c index 3574fac18..a26d80071 100644 --- a/src/rrdEventProcess.c +++ b/src/rrdEventProcess.c @@ -674,7 +674,6 @@ static void removeSpecialCharacterfromIssueTypeList(char *str) static int issueTypeSplitter(char *input_str, char *outsuffix, const char delimeter, char ***args) { int cnt = 1, i = 0; - char *str = input_str; char base[128] = {0}; char suffix[128] = {0}; From f509d0a9e14fdbadf0d52e041b023b22196561d7 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 1 May 2026 12:19:17 +0530 Subject: [PATCH 32/40] Update rrdJsonParser.c --- src/rrdJsonParser.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/rrdJsonParser.c b/src/rrdJsonParser.c index f141fbbe1..f4d4655fd 100644 --- a/src/rrdJsonParser.c +++ b/src/rrdJsonParser.c @@ -46,9 +46,19 @@ void removeSpecialChar(char *str) } } -// Utility to split base and suffix from issue type string -// Input: Device.DeviceTime_Search-b6877385-9463-45fc-b19d-a24d77fd0790 -// Output: base = Device.DeviceTime, suffix = _Search-b6877385-9463-45fc-b19d-a24d77fd0790 +/* + * @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; RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: [INFO] split_issue_type called with input='%s'\n", __FUNCTION__, __LINE__, input); From d10faa4a4bafcc10eafb7ab4b159688109691c92 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 1 May 2026 12:32:19 +0530 Subject: [PATCH 33/40] Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/rrdJsonParser.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rrdJsonParser.c b/src/rrdJsonParser.c index f4d4655fd..cc4be4dc8 100644 --- a/src/rrdJsonParser.c +++ b/src/rrdJsonParser.c @@ -61,6 +61,7 @@ void removeSpecialChar(char *str) void split_issue_type(const char *input, char *base, size_t base_len, char *suffix, size_t suffix_len) { if (!input || !base || !suffix) return; + if (base_len == 0 || suffix_len == 0) return; RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: [INFO] split_issue_type called with input='%s'\n", __FUNCTION__, __LINE__, input); const char *underscore = strchr(input, '_'); if (underscore) { From 58352611aa544ebb61884e9b28631acfdad9f3e0 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 1 May 2026 12:56:59 +0530 Subject: [PATCH 34/40] Update rrdEventProcess.c --- src/rrdEventProcess.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/rrdEventProcess.c b/src/rrdEventProcess.c index a26d80071..de16106e6 100644 --- a/src/rrdEventProcess.c +++ b/src/rrdEventProcess.c @@ -675,15 +675,15 @@ static int issueTypeSplitter(char *input_str, char *outsuffix, const char delime { int cnt = 1, i = 0; char *str = input_str; - char base[128] = {0}; - char suffix[128] = {0}; + char base[ BUF_LEN_128] = {0}; + char suffix[ BUF_LEN_128] = {0}; split_issue_type(str, base, sizeof(base), suffix, sizeof(suffix)); RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: [INFO] issueTypeSplitter (pre-clean): input='%s', base='%s', suffix='%s'\n", __FUNCTION__, __LINE__, str, base, suffix); // Copy base back to str so only the base is processed - strncpy(str, base, 128); + strncpy(str, base, BUF_LEN_128); - strncpy(outsuffix, suffix, 128); + strncpy(outsuffix, suffix, BUF_LEN_128); removeSpecialCharacterfromIssueTypeList(str); while (*str == delimeter) From c9dfeded060172bd72d746b7d6f4897c12d58f0b Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 1 May 2026 13:16:49 +0530 Subject: [PATCH 35/40] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/rrdJsonParser.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/rrdJsonParser.c b/src/rrdJsonParser.c index cc4be4dc8..fdf170d28 100644 --- a/src/rrdJsonParser.c +++ b/src/rrdJsonParser.c @@ -61,6 +61,16 @@ void removeSpecialChar(char *str) void split_issue_type(const char *input, char *base, size_t base_len, char *suffix, size_t suffix_len) { if (!input || !base || !suffix) return; + + if (base_len == 0 || suffix_len == 0) { + if (base && base_len > 0) { + base[0] = '\0'; + } + if (suffix && suffix_len > 0) { + suffix[0] = '\0'; + } + return; + } if (base_len == 0 || suffix_len == 0) return; RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: [INFO] split_issue_type called with input='%s'\n", __FUNCTION__, __LINE__, input); const char *underscore = strchr(input, '_'); From 3c19ac23cdeac8442b3b8471f7a319250dc948b0 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Fri, 1 May 2026 13:20:41 +0530 Subject: [PATCH 36/40] Update rrdJsonParser.c --- src/rrdJsonParser.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/rrdJsonParser.c b/src/rrdJsonParser.c index fdf170d28..388843352 100644 --- a/src/rrdJsonParser.c +++ b/src/rrdJsonParser.c @@ -71,8 +71,7 @@ void split_issue_type(const char *input, char *base, size_t base_len, char *suff } return; } - if (base_len == 0 || suffix_len == 0) return; - RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: [INFO] split_issue_type called with input='%s'\n", __FUNCTION__, __LINE__, input); + 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) { size_t b_len = underscore - input; @@ -86,7 +85,7 @@ void split_issue_type(const char *input, char *base, size_t base_len, char *suff base[base_len - 1] = '\0'; suffix[0] = '\0'; } - RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: [INFO] split_issue_type result: base='%s', suffix='%s'\n", __FUNCTION__, __LINE__, base, suffix); + RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: split_issue_type result: base='%s', suffix='%s'\n", __FUNCTION__, __LINE__, base, suffix); } From 3084d7041f9111015aa1e5264fb7355a94be7733 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 2 May 2026 05:51:12 +0000 Subject: [PATCH 37/40] Fix heap overflow in issueTypeSplitter and memory leaks in suffix handling Agent-Logs-Url: https://github.com/rdkcentral/remote_debugger/sessions/fbc52780-966b-4912-825f-3030aa43c3e9 Co-authored-by: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> --- .gitignore | 25 ++++++++++++++ src/rrdEventProcess.c | 30 ++++++++++++----- src/rrdJsonParser.c | 16 +++++++++ src/unittest/UTJson/device.properties | 0 src/unittest/rrdUnitTestRunner.cpp | 47 ++++++++++++++++++++++++--- 5 files changed, 106 insertions(+), 12 deletions(-) create mode 100644 .gitignore create mode 100644 src/unittest/UTJson/device.properties diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..6e090a1b4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,25 @@ +# Build artifacts +src/unittest/*.o +src/unittest/*.gcda +src/unittest/*.gcno +src/unittest/remotedebugger_gtest +src/unittest/Makefile +src/unittest/Makefile.in +src/unittest/aclocal.m4 +src/unittest/autom4te.cache/ +src/unittest/.deps/ +src/unittest/configure +src/unittest/config.log +src/unittest/config.status +src/unittest/compile +src/unittest/config.guess +src/unittest/config.sub +src/unittest/depcomp +src/unittest/install-sh +src/unittest/missing +src/unittest/COPYING +src/unittest/INSTALL + +# Temporary debug output directories +dummy_*/ +src/unittest/dummy_*/ diff --git a/src/rrdEventProcess.c b/src/rrdEventProcess.c index de16106e6..91bb6cdeb 100644 --- a/src/rrdEventProcess.c +++ b/src/rrdEventProcess.c @@ -73,7 +73,7 @@ void processIssueTypeEvent(data_buf *rbuf) free(rbuf->suffix); } rbuf->suffix = (suffix[0] != '\0') ? strdup(suffix) : NULL; - RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: [DEBUG] Assigned rbuf->suffix='%s' after issueTypeSplitter\n", __FUNCTION__, __LINE__, rbuf->suffix ? rbuf->suffix : "(null)"); + 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) { RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: IssueType Count [%d]... \n", __FUNCTION__, __LINE__, count); @@ -111,6 +111,11 @@ void processIssueTypeEvent(data_buf *rbuf) } if(cmdBuff) { + if (cmdBuff->suffix) + { + free(cmdBuff->suffix); + cmdBuff->suffix = NULL; + } free(cmdBuff); cmdBuff = NULL; } @@ -666,8 +671,13 @@ static void removeSpecialCharacterfromIssueTypeList(char *str) * @function issueTypeSplitter * @brief Splits a given string into tokens based on a specified delimiter, and removes any * special characters from the string before splitting. - * @param char *input_str - The input string to be split. - * @param const char delimiter - The character used to split the string. + * The first underscore in input_str is treated as a suffix separator: the base + * (part before the underscore) is written back into input_str, and the suffix + * (underscore + remainder) is written into outsuffix. + * @param char *input_str - The input string to be split (modified in place: base written back). + * @param char *outsuffix - Buffer (at least BUF_LEN_128 bytes) to receive the suffix portion, + * or NULL if the caller does not need the suffix. + * @param const char delimeter - The character used to split the string. * @param char ***args - Pointer to an array of strings where the tokens will be stored. * @return int - The number of tokens found in the string. */ @@ -678,12 +688,16 @@ static int issueTypeSplitter(char *input_str, char *outsuffix, const char delime char base[ BUF_LEN_128] = {0}; char suffix[ BUF_LEN_128] = {0}; split_issue_type(str, base, sizeof(base), suffix, sizeof(suffix)); - RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: [INFO] issueTypeSplitter (pre-clean): input='%s', base='%s', suffix='%s'\n", __FUNCTION__, __LINE__, str, base, suffix); + RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: issueTypeSplitter (pre-clean): input='%s', base='%s', suffix='%s'\n", __FUNCTION__, __LINE__, str, base, suffix); + + /* Copy only the actual base string back into str. base is always a prefix + * of the original str so it fits within the original allocation. */ + memmove(str, base, strlen(base) + 1); - // Copy base back to str so only the base is processed - strncpy(str, base, BUF_LEN_128); - - strncpy(outsuffix, suffix, BUF_LEN_128); + if (outsuffix != NULL) + { + snprintf(outsuffix, BUF_LEN_128, "%s", suffix); + } removeSpecialCharacterfromIssueTypeList(str); while (*str == delimeter) diff --git a/src/rrdJsonParser.c b/src/rrdJsonParser.c index 388843352..e483f3b0b 100644 --- a/src/rrdJsonParser.c +++ b/src/rrdJsonParser.c @@ -558,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; } @@ -578,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 @@ -638,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; } } } diff --git a/src/unittest/UTJson/device.properties b/src/unittest/UTJson/device.properties new file mode 100644 index 000000000..e69de29bb diff --git a/src/unittest/rrdUnitTestRunner.cpp b/src/unittest/rrdUnitTestRunner.cpp index 7b8c6c837..a24971bb6 100644 --- a/src/unittest/rrdUnitTestRunner.cpp +++ b/src/unittest/rrdUnitTestRunner.cpp @@ -1799,11 +1799,13 @@ TEST_F(RemoveItemTest, HandlesCacheNotNullAndCacheNotEqualsRrdCachecnode) node->mdata = strdup("PkgData"); node->issueString = strdup("IssueString"); node->next = NULL; + node->prev = NULL; cacheDataNode = node; cacheData *node_dummy = (cacheData *)malloc(sizeof(cacheData)); node_dummy->mdata = strdup("PkgData"); node_dummy->issueString = strdup("IssueString"); node_dummy->next = NULL; + node_dummy->prev = NULL; remove_item(node_dummy); EXPECT_NE(cacheDataNode, nullptr); @@ -1865,7 +1867,7 @@ TEST(IssueTypeSplitterTest, HandlesStringWithSpecialCharacters) { char str[] = "a@,b,&,cd,ef"; char **args = NULL; - int count = issueTypeSplitter(str, ',', &args); + int count = issueTypeSplitter(str, NULL, ',', &args); ASSERT_EQ(count, 4); ASSERT_STREQ(args[0], "a"); @@ -1884,7 +1886,7 @@ TEST(IssueTypeSplitterTest, HandlesStringWithNoSpecialCharacters) { char str[] = "abcd"; char **args = NULL; - int count = issueTypeSplitter(str, ',', &args); + int count = issueTypeSplitter(str, NULL, ',', &args); ASSERT_EQ(count, 1); ASSERT_STREQ(args[0], "abcd"); @@ -1900,13 +1902,48 @@ TEST(IssueTypeSplitterTest, HandlesEmptyString) { char str[] = ""; char **args = NULL; - int count = issueTypeSplitter(str, ',', &args); + int count = issueTypeSplitter(str, NULL, ',', &args); ASSERT_EQ(count, 1); free(args); } +TEST(IssueTypeSplitterTest, ExtractsSuffixFromIssueType) +{ + char str[] = "Device.DeviceTime_Search"; + char outsuffix[128] = {0}; + char **args = NULL; + int count = issueTypeSplitter(str, outsuffix, ',', &args); + + ASSERT_EQ(count, 1); + ASSERT_STREQ(args[0], "Device.DeviceTime"); + ASSERT_STREQ(outsuffix, "_Search"); + + for (int i = 0; i < count; i++) + { + free(args[i]); + } + free(args); +} + +TEST(IssueTypeSplitterTest, NoSuffixWhenNoUnderscore) +{ + char str[] = "Device.Network"; + char outsuffix[128] = {0}; + char **args = NULL; + int count = issueTypeSplitter(str, outsuffix, ',', &args); + + ASSERT_EQ(count, 1); + ASSERT_STREQ(outsuffix, ""); + + for (int i = 0; i < count; i++) + { + free(args[i]); + } + free(args); +} + /* --------------- Test processIssueTypeInDynamicProfile() from rrdEventProcess --------------- */ class ProcessIssueTypeInDynamicProfileTest : public ::testing::Test { @@ -1989,11 +2026,13 @@ TEST(ProcessIssueTypeEvntTest, RBufIsNull){ } TEST(ProcessIssueTypeEvntTest, inDynamic_NoJson){ - data_buf rbuf; + data_buf rbuf = {}; rbuf.mdata = strdup("a"); rbuf.inDynamic = true; rbuf.jsonPath = nullptr; processIssueTypeEvent(&rbuf); + free(rbuf.mdata); + rbuf.mdata = NULL; } /* ======================== rrdExecuteScript ==============*/ From eca3fb2981f55bb05f803a8e81f00d2097aadf79 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Sat, 2 May 2026 11:35:01 +0530 Subject: [PATCH 38/40] Update rrdUnitTestRunner.cpp --- src/unittest/rrdUnitTestRunner.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/unittest/rrdUnitTestRunner.cpp b/src/unittest/rrdUnitTestRunner.cpp index a24971bb6..ec013ab76 100644 --- a/src/unittest/rrdUnitTestRunner.cpp +++ b/src/unittest/rrdUnitTestRunner.cpp @@ -3723,6 +3723,7 @@ TEST_F(RRDEventThreadFuncTest, MessageReceiveSuccessEventMsgType) { rbuf.mdata = strdup("Test"); rbuf.inDynamic = true; rbuf.jsonPath = nullptr; + rbuf.suffix = nullptr msgRRDHdr msgHdr; msgHdr.mbody = malloc(sizeof(data_buf)); ASSERT_NE(msgHdr.mbody, nullptr); From 2cca47b260d2bc9b447694b74b0ca28cd65756f5 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Sat, 2 May 2026 11:35:39 +0530 Subject: [PATCH 39/40] Delete .gitignore --- .gitignore | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 .gitignore diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 6e090a1b4..000000000 --- a/.gitignore +++ /dev/null @@ -1,25 +0,0 @@ -# Build artifacts -src/unittest/*.o -src/unittest/*.gcda -src/unittest/*.gcno -src/unittest/remotedebugger_gtest -src/unittest/Makefile -src/unittest/Makefile.in -src/unittest/aclocal.m4 -src/unittest/autom4te.cache/ -src/unittest/.deps/ -src/unittest/configure -src/unittest/config.log -src/unittest/config.status -src/unittest/compile -src/unittest/config.guess -src/unittest/config.sub -src/unittest/depcomp -src/unittest/install-sh -src/unittest/missing -src/unittest/COPYING -src/unittest/INSTALL - -# Temporary debug output directories -dummy_*/ -src/unittest/dummy_*/ From f44f13170d9865f7f5dd5f4cffe263704b1b9208 Mon Sep 17 00:00:00 2001 From: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Date: Sat, 2 May 2026 13:35:10 +0530 Subject: [PATCH 40/40] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- src/unittest/rrdUnitTestRunner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unittest/rrdUnitTestRunner.cpp b/src/unittest/rrdUnitTestRunner.cpp index ec013ab76..8e34452ed 100644 --- a/src/unittest/rrdUnitTestRunner.cpp +++ b/src/unittest/rrdUnitTestRunner.cpp @@ -3723,7 +3723,7 @@ TEST_F(RRDEventThreadFuncTest, MessageReceiveSuccessEventMsgType) { rbuf.mdata = strdup("Test"); rbuf.inDynamic = true; rbuf.jsonPath = nullptr; - rbuf.suffix = nullptr + rbuf.suffix = nullptr; msgRRDHdr msgHdr; msgHdr.mbody = malloc(sizeof(data_buf)); ASSERT_NE(msgHdr.mbody, nullptr);