Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
4945e4c
Update rrdEventProcess.c
Abhinavpv28 May 3, 2026
8c0f9ee
Update rrdJsonParser.c
Abhinavpv28 May 3, 2026
c071798
Update rrdJsonParser.c
Abhinavpv28 May 3, 2026
c3b302b
Update rrdJsonParser.h
Abhinavpv28 May 3, 2026
dbe0d2c
Update rrdEventProcess.c
Abhinavpv28 May 3, 2026
b60dc49
Update rrdExecuteScript.h
Abhinavpv28 May 3, 2026
942ea5f
Update rrdExecuteScript.h
Abhinavpv28 May 3, 2026
c2a4b50
Update rrdJsonParser.c
Abhinavpv28 May 3, 2026
0b5b202
Update rrdJsonParser.c
Abhinavpv28 May 3, 2026
53ddee2
Update rrdEventProcess.c
Abhinavpv28 May 3, 2026
cf41c44
Update rrdJsonParser.c
Abhinavpv28 May 3, 2026
538d0b5
Update rrdEventProcess.c
Abhinavpv28 May 3, 2026
0ee897a
Update rrdJsonParser.c
Abhinavpv28 May 3, 2026
d426626
Update rrdEventProcess.c
Abhinavpv28 May 3, 2026
35e0fae
Update rrdEventProcess.c
Abhinavpv28 May 3, 2026
5b48bf6
Update rrdExecuteScript.h
Abhinavpv28 May 3, 2026
63df92c
Update rrdJsonParser.h
Abhinavpv28 May 3, 2026
5edb6dd
Update rrdEventProcess.c
Abhinavpv28 May 3, 2026
9ed06dd
Update rrdEventProcess.c
Abhinavpv28 May 3, 2026
1c0cf82
Add GTest test cases for split_issue_type, persist_suffix_to_file, an…
Copilot May 3, 2026
32c5fd5
Remove build artifacts and add .gitignore
Copilot May 3, 2026
e4afa18
Remove build-generated device.properties from tracking
Copilot May 3, 2026
447298c
Update rrdJsonParser.c
Abhinavpv28 May 3, 2026
1f7555f
Move suffix file clearing after upload success
Abhinavpv28 May 4, 2026
ca6e2b1
Potential fix for pull request finding
Abhinavpv28 May 4, 2026
3010e95
Potential fix for pull request finding
Abhinavpv28 May 4, 2026
768421c
Potential fix for pull request finding
Abhinavpv28 May 4, 2026
2cf9e9e
Update rrdEventProcess.c
Abhinavpv28 May 4, 2026
73a9022
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
1a656c9
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
66dab90
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
ee73b5f
Update rrdEventProcess.c
Abhinavpv28 May 4, 2026
a92b176
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
7ebde8e
Potential fix for pull request finding
Abhinavpv28 May 4, 2026
4bbca62
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
b96eb55
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
be09209
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
edb1a3e
Improve error handling in persist_suffix_to_file
Abhinavpv28 May 4, 2026
c619616
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
a194be8
Potential fix for pull request finding
Abhinavpv28 May 4, 2026
ab3aacc
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
40187fa
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
362f1ae
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
8bc8315
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
9887ec7
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
1afb92b
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
33a0011
Update rrdUnitTestRunner.cpp
Abhinavpv28 May 4, 2026
0fa6173
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
23b7ad3
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
23f2c67
Delete .gitignore
Abhinavpv28 May 4, 2026
c7b743a
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
e30155e
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
d3c7fe9
Potential fix for pull request finding
Abhinavpv28 May 4, 2026
2e1057a
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
11c6577
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
83ed3fc
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
36fdc38
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
9626d79
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
45ae798
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
d2c3ffa
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
49bc54f
Update rrdEventProcess.c
Abhinavpv28 May 4, 2026
30e9c95
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
6542863
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
dff2b1e
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
021cb29
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
d455cf6
Update rrdUnitTestRunner.cpp
Abhinavpv28 May 4, 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
25 changes: 21 additions & 4 deletions src/rrdEventProcess.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ void processIssueTypeEvent(data_buf *rbuf)
cmdBuff = (data_buf *)malloc(sizeof(data_buf));
if (cmdBuff)
{
dataMsgLen = strlen(cmdMap[index]) + 1;
char base[BUF_LEN_128] = {0};
char local_suffix[BUF_LEN_128] = {0};
split_issue_type(cmdMap[index], base, sizeof(base), local_suffix, sizeof(local_suffix));
dataMsgLen = strlen(base) + 1;
RRD_data_buff_init(cmdBuff, EVENT_MSG, RRD_DEEPSLEEP_INVALID_DEFAULT); /* Setting Deafult Values*/
Comment on lines +82 to 86
cmdBuff->inDynamic = rbuf->inDynamic;
if(cmdBuff->inDynamic)
Expand All @@ -88,9 +91,23 @@ void processIssueTypeEvent(data_buf *rbuf)
}
cmdBuff->appendMode = rbuf->appendMode;
cmdBuff->mdata = (char *)calloc(1, dataMsgLen);
/* Suffix is now persisted via file, no struct field needed */
if (cmdBuff->mdata)
{
strncpy((char *)cmdBuff->mdata, cmdMap[index], dataMsgLen);
strncpy((char *)cmdBuff->mdata, base, dataMsgLen);
/* Only persist suffix if input contains an underscore (i.e., is not just the base name) */
if (strchr(cmdMap[index], '_') && local_suffix[0] != '\0')
{
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: [DEBUG] Persisting suffix: '%s' from input: '%s' (index=%d)\n", __FUNCTION__, __LINE__, local_suffix, cmdMap[index], index);
if (persist_suffix_to_file(local_suffix) != 0)
{
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: [ERROR] Failed to persist suffix '%s' from input: '%s' (index=%d)\n", __FUNCTION__, __LINE__, local_suffix, cmdMap[index], index);
Comment on lines +101 to +104
}
}
Comment on lines +99 to +106
else
{
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: [DEBUG] Not persisting suffix for input: '%s' (index=%d)\n", __FUNCTION__, __LINE__, cmdMap[index], index);
}
Comment thread
Abhinavpv28 marked this conversation as resolved.
Comment on lines +98 to +110
Comment on lines 82 to +110
processIssueType(cmdBuff);
Comment on lines 82 to 111
}
else
Expand Down Expand Up @@ -628,7 +645,7 @@ static void freeParsedJson(cJSON *jsonParsed)
/*
* @function removeSpecialCharacterfromIssueTypeList
* @brief Removes special characters from the issue type list, retaining only alphanumeric
* characters, commas, and periods.
* characters, commas, periods, underscores and hyphens
* @param char *str - The string from which special characters will be removed.
* @return void
*/
Expand All @@ -639,7 +656,7 @@ static void removeSpecialCharacterfromIssueTypeList(char *str)

while (str[source] != '\0')
{
if (isalnum(str[source]) || str[source] == ',' || str[source] == '.')
if (isalnum((unsigned char)str[source]) || str[source] == ',' || str[source] == '.' || str[source] == '_'|| str[source] == '-')
{
str[destination] = str[source];
++destination;
Expand Down
262 changes: 261 additions & 1 deletion src/rrdJsonParser.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@
#include "rrdCommandSanity.h"
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
Comment thread
Abhinavpv28 marked this conversation as resolved.
#include <ctype.h>
#include <errno.h>
#include <limits.h>

#define RRD_SUFFIX_DIR "/tmp/rrd"
#define RRD_SUFFIX_PATH "/tmp/rrd/rrd_suffix.txt"
Comment on lines +31 to +32


/*
* @function removeSpecialChar
Expand All @@ -46,6 +53,225 @@ void removeSpecialChar(char *str)
}
}

int persist_suffix_to_file(const char *suffix) {
struct stat st;
uid_t uid = getuid();
Comment thread
Abhinavpv28 marked this conversation as resolved.
int dirfd = open(RRD_SUFFIX_DIR, O_NOFOLLOW | O_DIRECTORY);
if (dirfd == -1) {
// Directory does not exist, try to create
if (mkdir(RRD_SUFFIX_DIR, 0700) != 0 && errno != EEXIST) {
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: [ERROR] Failed to create %s: %s\n", __FUNCTION__, __LINE__, RRD_SUFFIX_DIR, strerror(errno));
return -1;
}
dirfd = open(RRD_SUFFIX_DIR, O_NOFOLLOW | O_DIRECTORY);
if (dirfd == -1) {
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: [ERROR] Could not open %s after creation: %s\n", __FUNCTION__, __LINE__, RRD_SUFFIX_DIR, strerror(errno));
return -1;
}
}
if (fstat(dirfd, &st) != 0 || !S_ISDIR(st.st_mode) || st.st_uid != uid || (st.st_mode & 0777) != 0700) {
Comment thread
Abhinavpv28 marked this conversation as resolved.
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: [ERROR] %s not owned by current user or not mode 0700!\n", __FUNCTION__, __LINE__, RRD_SUFFIX_DIR);
Comment thread
Abhinavpv28 marked this conversation as resolved.
close(dirfd);
Comment thread
Abhinavpv28 marked this conversation as resolved.
return -1;
}
Comment thread
Abhinavpv28 marked this conversation as resolved.
Comment on lines 31 to +76
Comment on lines +56 to +76
close(dirfd);
Comment thread
Abhinavpv28 marked this conversation as resolved.

// Write to a temp file first
char tmp_path[256];
snprintf(tmp_path, sizeof(tmp_path), "%s/.rrd_suffix.tmpXXXXXX", RRD_SUFFIX_DIR);
mode_t old_umask = umask(077);
int tmpfd = mkstemp(tmp_path);
Comment thread
Abhinavpv28 marked this conversation as resolved.
umask(old_umask);
if (tmpfd == -1) {
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: [ERROR] Failed to create temp file in %s: %s\n", __FUNCTION__, __LINE__, RRD_SUFFIX_DIR, strerror(errno));
return -1;
}
// Set restrictive permissions
if (fchmod(tmpfd, 0600) != 0) {
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: [ERROR] Failed to set permissions on temp file: %s\n", __FUNCTION__, __LINE__, strerror(errno));
close(tmpfd);
if (unlink(tmp_path) != 0) {
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: [ERROR] unlink failed on %s: %s\n", __FUNCTION__, __LINE__, tmp_path, strerror(errno));
}
return -1;
}
// Write suffix
Comment thread
Abhinavpv28 marked this conversation as resolved.
if (suffix && suffix[0] != '\0') {
size_t len = strlen(suffix);
size_t total_written = 0;
while (total_written < len) {
/* Coverity fix: ensure no underflow/overflow in len - total_written */
Comment thread
Abhinavpv28 marked this conversation as resolved.
if (total_written > len) {
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: [ERROR] total_written (%zu) > len (%zu), possible integer overflow\n", __FUNCTION__, __LINE__, total_written, len);
close(tmpfd);
if (unlink(tmp_path) != 0) {
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: [ERROR] unlink failed on %s: %s\n", __FUNCTION__, __LINE__, tmp_path, strerror(errno));
}
return -1;
}
size_t to_write = len - total_written;
if (to_write > SSIZE_MAX) {
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: [ERROR] to_write (%zu) > SSIZE_MAX (%zd), refusing to write\n", __FUNCTION__, __LINE__, to_write, (ssize_t)SSIZE_MAX);
close(tmpfd);
Comment thread
Abhinavpv28 marked this conversation as resolved.
Comment on lines +112 to +115
if (unlink(tmp_path) != 0) {
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: [ERROR] unlink failed on %s: %s\n", __FUNCTION__, __LINE__, tmp_path, strerror(errno));
}
return -1;
}
if (to_write == 0) {
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: [ERROR] to_write is 0, nothing to write\n", __FUNCTION__, __LINE__);
close(tmpfd);
if (unlink(tmp_path) != 0) {
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: [ERROR] unlink failed on %s: %s\n", __FUNCTION__, __LINE__, tmp_path, strerror(errno));
}
return -1;
}
/* Defensive: never cast a negative value, but size_t is unsigned, so only check upper bound */
ssize_t write_len = (ssize_t)to_write;
if (write_len <= 0) {
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: [ERROR] write_len (%zd) <= 0, refusing to write\n", __FUNCTION__, __LINE__, write_len);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverity Issue - Logically dead code

Execution cannot reach this statement: "rdk_logger_msg_printf(RDK_L...".

Medium Impact, CWE-561
DEADCODE

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverity Issue - Logically dead code

Execution cannot reach this statement: "rdk_logger_msg_printf(RDK_L...".

Medium Impact, CWE-561
DEADCODE

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverity Issue - Logically dead code

Execution cannot reach this statement: "rdk_logger_msg_printf(RDK_L...".

Medium Impact, CWE-561
DEADCODE

close(tmpfd);
if (unlink(tmp_path) != 0) {
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: [ERROR] unlink failed on %s: %s\n", __FUNCTION__, __LINE__, tmp_path, strerror(errno));
}
return -1;
}
ssize_t written = write(tmpfd, suffix + total_written, write_len);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverity Issue - Overflowed integer argument

"write_len", which might have underflowed, is passed to "write(tmpfd, suffix + total_written, write_len)".

High Impact, CWE-190
INTEGER_OVERFLOW

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverity Issue - Overflowed integer argument

"write_len", which might have underflowed, is passed to "write(tmpfd, suffix + total_written, write_len)".

High Impact, CWE-190
INTEGER_OVERFLOW

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverity Issue - Overflowed integer argument

"write_len", which might have underflowed, is passed to "write(tmpfd, suffix + total_written, write_len)".

High Impact, CWE-190
INTEGER_OVERFLOW

if (written == -1) {
if (errno == EINTR)
continue;
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: [ERROR] Failed to write suffix to temp file: %s\n", __FUNCTION__, __LINE__, strerror(errno));
close(tmpfd);
if (unlink(tmp_path) != 0) {
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: [ERROR] unlink failed on %s: %s\n", __FUNCTION__, __LINE__, tmp_path, strerror(errno));
}
return -1;
}
if (written == 0) {
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: [ERROR] Short write (0 bytes) to temp file\n", __FUNCTION__, __LINE__);
close(tmpfd);
if (unlink(tmp_path) != 0) {
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: [ERROR] unlink failed on %s: %s\n", __FUNCTION__, __LINE__, tmp_path, strerror(errno));
}
return -1;
}
total_written += (size_t)written;
}
}
// Flush and verify
if (fsync(tmpfd) != 0) {
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: [ERROR] fsync failed on temp file: %s\n", __FUNCTION__, __LINE__, strerror(errno));
close(tmpfd);
if (unlink(tmp_path) != 0) {
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: [ERROR] unlink failed on %s: %s\n", __FUNCTION__, __LINE__, tmp_path, strerror(errno));
}
return -1;
}
struct stat fst;
if (fstat(tmpfd, &fst) != 0 || !S_ISREG(fst.st_mode)) {
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: [ERROR] Temp file is not a regular file!\n", __FUNCTION__, __LINE__);
close(tmpfd);
if (unlink(tmp_path) != 0) {
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: [ERROR] unlink failed on %s: %s\n", __FUNCTION__, __LINE__, tmp_path, strerror(errno));
}
return -1;
}
close(tmpfd);

// Atomically rename temp file to target
if (rename(tmp_path, RRD_SUFFIX_PATH) != 0) {
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: [ERROR] Failed to rename temp file to %s: %s\n", __FUNCTION__, __LINE__, RRD_SUFFIX_PATH, strerror(errno));
if (unlink(tmp_path) != 0) {
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: [ERROR] unlink failed on %s: %s\n", __FUNCTION__, __LINE__, tmp_path, strerror(errno));
}
return -1;
}
return 0;
}

void read_suffix_from_file_to_buf(char *buf, size_t buflen)
{
if (!buf || buflen == 0) return;
int fd = open(RRD_SUFFIX_PATH, O_RDONLY | O_NOFOLLOW | O_CLOEXEC);
if (fd == -1) {
buf[0] = '\0';
return;
}
struct stat st;
if (fstat(fd, &st) != 0 || !S_ISREG(st.st_mode) || st.st_uid != getuid() || (st.st_mode & 022) != 0) {
// Not a regular file, not owned by us, or group/other-writable
buf[0] = '\0';
close(fd);
return;
}
FILE *fp = fdopen(fd, "r");
if (!fp) {
buf[0] = '\0';
close(fd);
return;
}
if (fgets(buf, buflen, fp) == NULL) {
buf[0] = '\0';
fclose(fp);
return;
}
fclose(fp);
size_t len = strlen(buf);
if (len > 0 && buf[len-1] == '\n') buf[len-1] = '\0';
}

/*
* @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 (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;
}
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;
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_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.
Expand Down Expand Up @@ -516,6 +742,9 @@ 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
free(buff->jsonPath); // free rrd path info
if (persist_suffix_to_file("") != 0) {
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: [ERROR] Failed to clear suffix file on early exit\n", __FUNCTION__, __LINE__);
}
return;
}

Expand All @@ -536,6 +765,9 @@ void checkIssueNodeInfo(issueNodeData *issuestructNode, cJSON *jsoncfg, data_buf
free(rfcbuf); // free duplicated rfc data
free(buff->mdata); // free rfc data
free(buff->jsonPath); // free rrd path info
if (persist_suffix_to_file("") != 0) {
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: [ERROR] Failed to clear suffix file on early exit\n", __FUNCTION__, __LINE__);
}
return;
}
else
Expand Down Expand Up @@ -576,7 +808,29 @@ 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 file for upload
char suffix[128] = {0};
read_suffix_from_file_to_buf(suffix, sizeof(suffix));
char tarName[512] = {0};
int tar_name_len = 0;
if (suffix[0] != '\0') {
tar_name_len = snprintf(tarName, sizeof(tarName), "%s%s", buff->mdata, suffix);
}
else
{
tar_name_len = snprintf(tarName, sizeof(tarName), "%s", buff->mdata);
}
if ((tar_name_len < 0) || ((size_t)tar_name_len >= sizeof(tarName)))
Comment thread
Abhinavpv28 marked this conversation as resolved.
{
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
{
RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: [INFO] Tar file name for upload: '%s'\n", __FUNCTION__, __LINE__, tarName);
status = uploadDebugoutput(outdir, tarName);
}

Comment thread
Abhinavpv28 marked this conversation as resolved.
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 @@ -589,13 +843,19 @@ void checkIssueNodeInfo(issueNodeData *issuestructNode, cJSON *jsoncfg, data_buf
free(rfcbuf); // free duplicated rfc data
free(buff->mdata); // free rfc data
free(buff->jsonPath); // free rrd path info
if (persist_suffix_to_file("") != 0) {
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: [ERROR] Failed to clear suffix file after upload\n", __FUNCTION__, __LINE__);
}
}
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
free(buff->jsonPath); // free rrd path info
if (persist_suffix_to_file("") != 0) {
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: [ERROR] Failed to clear suffix file after upload\n", __FUNCTION__, __LINE__);
}
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/rrdJsonParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ issueData* getIssueCommandInfo(issueNodeData *issuestructNode, cJSON *jsoncfg,ch
bool processAllDebugCommand(cJSON *jsoncfg, issueNodeData *issuestructNode, char *rfcbuf);
bool processAllDeepSleepAwkMetricsCommands(cJSON *jsoncfg, issueNodeData *issuestructNode, char *rfcbuf);


int persist_suffix_to_file(const char *suffix);
void read_suffix_from_file_to_buf(char *buf, size_t buflen);
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