Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
cd795e2
Refactor issueTypeSplitter to include suffix handling
Abhinavpv28 Apr 30, 2026
a950f13
Update rrdEventProcess.c
Abhinavpv28 Apr 30, 2026
ba3c8ca
Update rrdExecuteScript.c
Abhinavpv28 Apr 30, 2026
63bc161
Refactor rrdEventProcess.h to rrdExecuteScript.h
Abhinavpv28 Apr 30, 2026
c883bd2
Update rrdExecuteScript.h
Abhinavpv28 Apr 30, 2026
9380442
Update rrdExecuteScript.h
Abhinavpv28 Apr 30, 2026
61a9e2c
Update rrdEventProcess.h
Abhinavpv28 Apr 30, 2026
d672210
Update rrdExecuteScript.h
Abhinavpv28 Apr 30, 2026
65d30d0
Update rrdJsonParser.c
Abhinavpv28 Apr 30, 2026
93df789
Update rrdJsonParser.h
Abhinavpv28 Apr 30, 2026
6d37d71
Update rrdInterface.c
Abhinavpv28 Apr 30, 2026
c7588d3
Update rrdCommon.h
Abhinavpv28 Apr 30, 2026
d1345ab
Update rrdEventProcess.c
Abhinavpv28 Apr 30, 2026
e720479
Update rrdEventProcess.c
Abhinavpv28 May 1, 2026
faacd2a
Update rrdEventProcess.c
Abhinavpv28 May 1, 2026
7daeac3
Update rrdEventProcess.c
Abhinavpv28 May 1, 2026
52539a3
Fix indentation for appendMode assignment
Abhinavpv28 May 1, 2026
ec1680e
Update rrdCommon.h
Abhinavpv28 May 1, 2026
bfb7f1e
Fix appendMode assignment in rrdEventProcess.c
Abhinavpv28 May 1, 2026
e71f82e
Update rrdEventProcess.c
Abhinavpv28 May 1, 2026
72b9562
Update rrdJsonParser.c
Abhinavpv28 May 1, 2026
e6b8690
Update rrdEventProcess.c
Abhinavpv28 May 1, 2026
79f6e64
Update rrdExecuteScript.h
Abhinavpv28 May 1, 2026
bd49f43
Update rrdExecuteScript.c
Abhinavpv28 May 1, 2026
3a5f988
Update rrdExecuteScript.c
Abhinavpv28 May 1, 2026
4587984
Update rrdExecuteScript.c
Abhinavpv28 May 1, 2026
5c3f460
Remove redundant logging from rrdJsonParser
Abhinavpv28 May 1, 2026
3d77c29
Update rrdJsonParser.c
Abhinavpv28 May 1, 2026
b5f062b
Update rrdEventProcess.c
Abhinavpv28 May 1, 2026
f21ad0f
Update rrdJsonParser.c
Abhinavpv28 May 1, 2026
02a0507
Update rrdEventProcess.c
Abhinavpv28 May 1, 2026
f509d0a
Update rrdJsonParser.c
Abhinavpv28 May 1, 2026
d10faa4
Apply suggestions from code review
Abhinavpv28 May 1, 2026
5835261
Update rrdEventProcess.c
Abhinavpv28 May 1, 2026
c9dfede
Apply suggestion from @Copilot
Abhinavpv28 May 1, 2026
3c19ac2
Update rrdJsonParser.c
Abhinavpv28 May 1, 2026
3084d70
Fix heap overflow in issueTypeSplitter and memory leaks in suffix han…
Copilot May 2, 2026
eca3fb2
Update rrdUnitTestRunner.cpp
Abhinavpv28 May 2, 2026
2cca47b
Delete .gitignore
Abhinavpv28 May 2, 2026
f44f131
Potential fix for pull request finding
Abhinavpv28 May 2, 2026
9a6cf0d
Update rrdEventProcess.c
Abhinavpv28 May 2, 2026
ae506f9
Update rrdEventProcess.c
Abhinavpv28 May 2, 2026
2e8a039
Update rrdEventProcess.c
Abhinavpv28 May 2, 2026
36587ee
Update rrdEventProcess.c
Abhinavpv28 May 2, 2026
acacbdb
Update rrdUnitTestRunner.cpp
Abhinavpv28 May 2, 2026
5fb10ce
Update rrdEventProcess.c
Abhinavpv28 May 3, 2026
6e21ca0
Update rrdUnitTestRunner.cpp
Abhinavpv28 May 3, 2026
8105959
Update rrdUnitTestRunner.cpp
Abhinavpv28 May 3, 2026
a87a726
Add gtest test cases for split_issue_type
Copilot May 3, 2026
617edf9
Remove build artifacts, add .gitignore
Copilot May 3, 2026
05e0cf8
Add explicit truncated content assertion in SuffixTruncatedWhenTooSma…
Copilot May 3, 2026
3a0687a
Apply suggestions from code review
Abhinavpv28 May 3, 2026
842577e
Update rrdEventProcess.c
Abhinavpv28 May 3, 2026
3b6ffba
Update rrdEventProcess.c
Abhinavpv28 May 3, 2026
638a63e
Update rrdEventProcess.c
Abhinavpv28 May 3, 2026
a889589
Update rrdEventProcess.c
Abhinavpv28 May 3, 2026
f78c999
Update rrdEventProcess.c
Abhinavpv28 May 3, 2026
8405fb2
Update rrdEventProcess.c
Abhinavpv28 May 3, 2026
0038f01
Update rrdEventProcess.c
Abhinavpv28 May 3, 2026
b445c8a
Update rrdEventProcess.c
Abhinavpv28 May 3, 2026
64dc355
Update rrdEventProcess.c
Abhinavpv28 May 3, 2026
0d9850a
Update rrdEventProcess.c
Abhinavpv28 May 3, 2026
ca8c14c
Update rrdEventProcess.c
Abhinavpv28 May 3, 2026
4cb74db
Update rrdEventProcess.c
Abhinavpv28 May 3, 2026
5bf24f2
Potential fix for pull request finding
Abhinavpv28 May 3, 2026
a44c0e8
Update rrdJsonParser.c
Abhinavpv28 May 3, 2026
3a798ef
Update rrdJsonParser.c
Abhinavpv28 May 3, 2026
c350bb0
Potential fix for pull request finding
Abhinavpv28 May 3, 2026
cf3a830
Potential fix for pull request finding
Abhinavpv28 May 3, 2026
1bc5ed3
Potential fix for pull request finding
Abhinavpv28 May 3, 2026
7d1e5ad
Update rrdUnitTestRunner.cpp
Abhinavpv28 May 3, 2026
f8519e1
Potential fix for pull request finding
Abhinavpv28 May 4, 2026
45e7d46
Potential fix for pull request finding
Abhinavpv28 May 4, 2026
9f2018d
Delete .gitignore
Abhinavpv28 May 4, 2026
94e5848
Delete src/unittest/UTJson/device.properties
Abhinavpv28 May 4, 2026
6aaa224
Update rrdEventProcess.c
Abhinavpv28 May 4, 2026
dcff40f
Add gtest tests for split_issue_type, suffix field, and processIssueT…
Copilot May 4, 2026
22f93ba
Delete .gitignore
Abhinavpv28 May 5, 2026
881aa5f
Validate suffix prefix: only _Search- and _LogSearch- are allowed
Copilot May 5, 2026
d031661
Base never contains underscore: split at first _ and discard invalid …
Copilot May 5, 2026
9a6b977
Update rrdEventProcess.c
Abhinavpv28 May 5, 2026
815b247
Update rrdUnitTestRunner.cpp
Abhinavpv28 May 5, 2026
43a64e1
Update rrdEventProcess.c
Abhinavpv28 May 5, 2026
31494a7
Update rrdEventProcess.c
Abhinavpv28 May 5, 2026
17289c1
Fix segfault in GTEST_ENABLE mode when rbuf->jsonPath is NULL
Copilot May 5, 2026
5c8ffb8
Remove accidentally committed dummy directory and update .gitignore
Copilot May 5, 2026
2d65f7e
Fix IssueTypeSplitterTest to match new issueTypeSplitter behavior (no…
Copilot May 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Autotools build artifacts
Makefile.in
aclocal.m4
autom4te.cache/
compile
config.guess
config.h.in
config.log
config.sub
configure
depcomp
install-sh
ltmain.sh
m4/libtool.m4
m4/ltoptions.m4
m4/ltsugar.m4
m4/ltversion.m4
m4/lt~obsolete.m4
missing
config.status
Makefile
src/Makefile
src/unittest/Makefile

# Build output files
*.o
*.a
*.so
*.lo
*.la
*.Po
*.Plo
*.gcda
*.gcno
*.gcov
.deps/
.libs/

# Test binaries and coverage output
src/unittest/remotedebugger_gtest
src/unittest/COPYING
src/unittest/INSTALL
src/unittest/dummy_*/

# Generated test data files
src/unittest/UTJson/device.properties
dummy_*/
1 change: 1 addition & 0 deletions src/rrdCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,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*/
Expand Down
49 changes: 44 additions & 5 deletions src/rrdEventProcess.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,23 @@ void processIssueTypeEvent(data_buf *rbuf)
cmdBuff = (data_buf *)malloc(sizeof(data_buf));
if (cmdBuff)
{
dataMsgLen = strlen(cmdMap[index]) + 1;
char base[128] = {0};
char local_suffix[128] = {0};
split_issue_type(cmdMap[index], base, sizeof(base), local_suffix, sizeof(local_suffix));
if (base[0] == '\0')
{
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: Empty issue type after parsing token [%s], skipping... \n", __FUNCTION__, __LINE__, cmdMap[index]);
free(cmdBuff);
cmdBuff = NULL;
if (cmdMap[index])
{
free(cmdMap[index]);
cmdMap[index] = NULL;
}
continue;
}
dataMsgLen = strlen(base) + 1;
removeSpecialCharacterfromIssueTypeList(base);
RRD_data_buff_init(cmdBuff, EVENT_MSG, RRD_DEEPSLEEP_INVALID_DEFAULT); /* Setting Deafult Values*/
cmdBuff->inDynamic = rbuf->inDynamic;
if(cmdBuff->inDynamic)
Expand All @@ -88,9 +104,19 @@ void processIssueTypeEvent(data_buf *rbuf)
}
Comment on lines 98 to 104
cmdBuff->appendMode = rbuf->appendMode;
Comment thread
Abhinavpv28 marked this conversation as resolved.
Comment on lines 99 to 105
cmdBuff->mdata = (char *)calloc(1, dataMsgLen);

/* Store suffix for this issue type */
cmdBuff->suffix = NULL;
if (local_suffix[0] != '\0') {
cmdBuff->suffix = strdup(local_suffix);
if (cmdBuff->suffix == NULL)
{
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: Failed to allocate memory for suffix... \n", __FUNCTION__, __LINE__);
}
}
if (cmdBuff->mdata)
{
strncpy((char *)cmdBuff->mdata, cmdMap[index], dataMsgLen);
strncpy((char *)cmdBuff->mdata, base, dataMsgLen);
processIssueType(cmdBuff);
}
else
Expand All @@ -99,6 +125,11 @@ void processIssueTypeEvent(data_buf *rbuf)
}
if(cmdBuff)
{
if (cmdBuff->suffix)
{
free(cmdBuff->suffix);
cmdBuff->suffix = NULL;
}
free(cmdBuff);
cmdBuff = NULL;
}
Expand Down Expand Up @@ -392,7 +423,10 @@ static void processIssueTypeInStaticProfile(data_buf *rbuf, issueNodeData *pIssu
#if !defined(GTEST_ENABLE)
jsonParsed = readAndParseJSON(RRD_JSON_FILE);
#else
jsonParsed = readAndParseJSON(rbuf->jsonPath);
if (rbuf->jsonPath != NULL)
{
jsonParsed = readAndParseJSON(rbuf->jsonPath);
}
#endif
if (jsonParsed == NULL)
{ // Static Profile JSON Parsing or Read Fail
Expand Down Expand Up @@ -555,6 +589,11 @@ static void processIssueTypeInInstalledPackage(data_buf *rbuf, issueNodeData *pI
suffixlen = strlen(RDM_PKG_SUFFIX);
dynJSONPath = (char *)malloc(persistentAppslen + prefixlen + suffixlen + strlen(pIssueNode->Node) + rrdjsonlen + 1);
#else
if (rbuf->jsonPath == NULL)
{
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: jsonPath is NULL in GTEST mode, skipping installed package check... \n", __FUNCTION__, __LINE__);
return;
}
int utjsonlen = strlen(rbuf->jsonPath);
dynJSONPath = (char *)malloc(utjsonlen + 1);
#endif
Expand Down Expand Up @@ -639,7 +678,8 @@ static void removeSpecialCharacterfromIssueTypeList(char *str)

while (str[source] != '\0')
{
if (isalnum(str[source]) || str[source] == ',' || str[source] == '.')
//if (isalnum(str[source]) || str[source] == ',' || str[source] == '.' || str[source] == '_'|| str[source] == '-')
if (isalnum(str[source]) || str[source] == ',' || str[source] == '.')
Comment on lines 678 to +682
{
Comment thread
Abhinavpv28 marked this conversation as resolved.
Comment on lines 679 to 683
str[destination] = str[source];
++destination;
Expand All @@ -663,7 +703,6 @@ static int issueTypeSplitter(char *input_str, const char delimeter, char ***args
int cnt = 1, i = 0;
char *str = input_str;

removeSpecialCharacterfromIssueTypeList(str);
while (*str == delimeter)
str++;

Expand Down
5 changes: 5 additions & 0 deletions src/rrdInterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -295,6 +296,10 @@ void RRD_data_buff_deAlloc(data_buf *sbuf)
{
free(sbuf->jsonPath);
}
if (sbuf->suffix)
{
free(sbuf->suffix);
}
Comment thread
Abhinavpv28 marked this conversation as resolved.
free(sbuf);
}
}
Expand Down
119 changes: 118 additions & 1 deletion src/rrdJsonParser.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,88 @@ void removeSpecialChar(char *str)
}
}

/* Valid suffix prefixes: only "_Search-" and "_LogSearch-" are accepted */
#define VALID_SUFFIX_SEARCH "_Search-"
#define VALID_SUFFIX_LOGSEARCH "_LogSearch-"

/*
* @function split_issue_type
* @brief Utility to split base and suffix from issue type string.
* The input is always split at the first '_'. The base is the part
* before the underscore (never contains '_'). The suffix is only
* populated when it starts with "_Search-" or "_LogSearch-"; any
* other underscore-delimited token is discarded (suffix returns "").
* If no underscore is present the full input is the base.
* Examples:
* "Device.DeviceTime_Search-b6877385" → base="Device.DeviceTime",
* suffix="_Search-b6877385"
* "Device.DeviceTime_LogSearch-1a2b" → base="Device.DeviceTime",
* suffix="_LogSearch-1a2b"
* "Device.DeviceTime_Other-token" → base="Device.DeviceTime",
* suffix=""
* "Device.DeviceTime" → base="Device.DeviceTime",
* suffix=""
* @param const char *input - The input string to split.
* @param char *base - Buffer to store the base part (never contains '_').
* @param size_t base_len - Size of the base buffer.
* @param char *suffix - Buffer to store the suffix part when valid, else "".
* @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 (base && base_len > 0)
{
base[0] = '\0';
}
if (suffix && suffix_len > 0)
{
suffix[0] = '\0';
}

if (!input || !base || !suffix)
{
return;
}

if (base_len == 0 || suffix_len == 0)
{
return;
}

Comment on lines +80 to +98
const char *underscore = strchr(input, '_');
if (underscore)
{
/* Always split at the first underscore — base never contains '_' */
size_t b_len = (size_t)(underscore - input);
if (b_len >= base_len) b_len = base_len - 1;
strncpy(base, input, b_len);
base[b_len] = '\0';

/* Only carry the suffix when it starts with an allowed prefix */
if (strncmp(underscore, VALID_SUFFIX_SEARCH, sizeof(VALID_SUFFIX_SEARCH) - 1) == 0 ||
strncmp(underscore, VALID_SUFFIX_LOGSEARCH, sizeof(VALID_SUFFIX_LOGSEARCH) - 1) == 0)
{
strncpy(suffix, underscore, suffix_len - 1);
suffix[suffix_len - 1] = '\0';
}
else
{
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Suffix after '%s' does not start with an allowed prefix; discarding suffix\n", __FUNCTION__, __LINE__, base);
suffix[0] = '\0';
}
}
else
{
/* No underscore — full input is the base */
strncpy(base, input, base_len - 1);
base[base_len - 1] = '\0';
suffix[0] = '\0';
}
}


/*
* @function getParamcount
* @brief Calculates the total number of nodes (elements) in the input string, excluding delimiters.
Expand Down Expand Up @@ -515,7 +597,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;
Comment thread
Abhinavpv28 marked this conversation as resolved.
return;
}

Expand All @@ -535,7 +621,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
Expand Down Expand Up @@ -576,7 +666,26 @@ 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};
int tar_name_len = 0;
if (buff->suffix && buff->suffix[0] != '\0')
{
tar_name_len = snprintf(tarName, sizeof(tarName), "%s%s", buff->mdata, buff->suffix);
}
else
{
tar_name_len = snprintf(tarName, sizeof(tarName), "%s", buff->mdata);
}
if ((tar_name_len < 0) || ((size_t)tar_name_len >= sizeof(tarName)))
{
RDK_LOG(RDK_LOG_ERROR,LOG_REMDEBUG,"[%s:%d]: Failed to build upload file name for %s. snprintf result:%d, buffer size:%zu\n", __FUNCTION__,__LINE__,buff->mdata,tar_name_len,sizeof(tarName));
status = -1;
}
else
{
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);
Expand All @@ -588,14 +697,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;
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/rrdJsonParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading
Loading