-
Notifications
You must be signed in to change notification settings - Fork 4
Feature/getprof rrd #450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Feature/getprof rrd #450
Changes from all commits
4f187e0
abdcc7b
ba8bd7e
12c1bfe
eb904ac
0174a05
d58538b
815f4ef
0a98c08
f91e99f
8d9e660
439a2f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -168,6 +168,12 @@ XRFCStorage hostIf_DeviceInfo::m_rfcStorage; | |||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||
| XBSStore* hostIf_DeviceInfo::m_bsStore; | ||||||||||||||||||||||||||||||||
| string hostIf_DeviceInfo::m_xrPollingAction = "0"; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| #ifdef USE_REMOTE_DEBUGGER | ||||||||||||||||||||||||||||||||
| string hostIf_DeviceInfo::m_rdkRemoteDebuggerProfileCategory = "all"; | ||||||||||||||||||||||||||||||||
| string hostIf_DeviceInfo::m_rdkRemoteDebuggerProfileData; | ||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| #ifndef RDKV_TR69 | ||||||||||||||||||||||||||||||||
| static bool bPowerControllerEnable; | ||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||
|
|
@@ -4043,6 +4049,10 @@ int hostIf_DeviceInfo::set_xRDKCentralComRFC(HOSTIF_MsgData_t * stMsgData) | |||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| ret = set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerWebCfgData(stMsgData); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| else if (strcasecmp(stMsgData->paramName,RDK_REMOTE_DEBUGGER_SET_PROFILE_DATA) == 0) | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| ret = set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggersetProfileData(stMsgData); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||
| else if (strcasecmp(stMsgData->paramName,CANARY_START_TIME) == 0) | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
|
|
@@ -4164,6 +4174,32 @@ int hostIf_DeviceInfo::set_xRDKCentralComNewNtpEnable(HOSTIF_MsgData_t *stMsgDat | |||||||||||||||||||||||||||||||
| return ret; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| #ifdef USE_REMOTE_DEBUGGER | ||||||||||||||||||||||||||||||||
| int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggersetProfileData(HOSTIF_MsgData_t *stMsgData) | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| int ret = NOK; | ||||||||||||||||||||||||||||||||
| LOG_ENTRY_EXIT; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| if (stMsgData->paramtype == hostIf_StringType) | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| // Store the category value to decide what to return in getProfileData | ||||||||||||||||||||||||||||||||
| m_rdkRemoteDebuggerProfileCategory = stMsgData->paramValue; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s] Remote Debugger Profile Data category set to: %s\n", | ||||||||||||||||||||||||||||||||
| __FUNCTION__, stMsgData->paramValue); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| ret = OK; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s:%d] Failed due to wrong data type for %s, please use string type.\n", | ||||||||||||||||||||||||||||||||
| __FUNCTION__, __LINE__, stMsgData->paramName); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| return ret; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| #endif /* USE_REMOTE_DEBUGGER */ | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| int hostIf_DeviceInfo::get_xRDKCentralComBootstrap(HOSTIF_MsgData_t *stMsgData) | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| return m_bsStore->getValue(stMsgData); | ||||||||||||||||||||||||||||||||
|
|
@@ -4196,6 +4232,8 @@ int hostIf_DeviceInfo::get_xRDKCentralComRFC(HOSTIF_MsgData_t *stMsgData) | |||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| return ret; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
|
@@ -4319,121 +4357,196 @@ int hostIf_DeviceInfo::set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggerI | |||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| int hostIf_DeviceInfo::get_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggergetProfileData(HOSTIF_MsgData_t *stMsgData) | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| stMsgData->paramtype = hostIf_StringType; | ||||||||||||||||||||||||||||||||
| stMsgData->paramtype = hostIf_StringType; | ||||||||||||||||||||||||||||||||
| int retStatus = NOK; | ||||||||||||||||||||||||||||||||
| const char *filename = "/etc/rrd/remote_debugger.json"; | ||||||||||||||||||||||||||||||||
| FILE *fp = nullptr; | ||||||||||||||||||||||||||||||||
| char *fileBuf = nullptr; | ||||||||||||||||||||||||||||||||
| long fileSz = 0; | ||||||||||||||||||||||||||||||||
| size_t bytesRead = 0; | ||||||||||||||||||||||||||||||||
| cJSON *root = nullptr; | ||||||||||||||||||||||||||||||||
| cJSON *filtered = nullptr; | ||||||||||||||||||||||||||||||||
| cJSON *response = nullptr; | ||||||||||||||||||||||||||||||||
| char *outStr = nullptr; | ||||||||||||||||||||||||||||||||
| size_t outLen = 0; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| RDK_LOG(RDK_LOG_TRACE1, LOG_TR69HOSTIF, "[%s] Entering …\n", __FUNCTION__); | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
| RDK_LOG(RDK_LOG_TRACE1, LOG_TR69HOSTIF, "[%s] Entering …\n", __FUNCTION__); | |
| RDK_LOG(RDK_LOG_TRACE1, LOG_TR69HOSTIF, "[%s] Entering ...\n", __FUNCTION__); |
Copilot
AI
Apr 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fread's return value isn’t validated against the expected file size and ferror(fp) isn’t checked. A short read can lead to parsing truncated JSON and returning misleading data. Consider treating bytesRead != (size_t)fileSz as an error (or loop until EOF) and handle ferror explicitly.
| bytesRead = fread(fileBuf, 1U, (size_t)fileSz, fp); | |
| bytesRead = fread(fileBuf, 1U, (size_t)fileSz, fp); | |
| if (bytesRead != (size_t)fileSz) { | |
| if (ferror(fp)) { | |
| RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] fread failed for %s\n", __FUNCTION__, filename); | |
| } else { | |
| RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Short read for %s: expected %ld bytes, got %zu bytes\n", | |
| __FUNCTION__, filename, fileSz, bytesRead); | |
| } | |
| fclose(fp); | |
| fp = nullptr; | |
| free(fileBuf); | |
| fileBuf = nullptr; | |
| return retStatus; | |
| } |
Copilot
AI
Apr 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When building the JSON response, cJSON_AddItemToObject(response, category->string, ...) assumes category->string is non-null. If /etc/rrd/remote_debugger.json ever contains an array (or any non-object root/child), category->string can be null and this will crash. Please validate root is an object and guard category->string before using it as an object key.
Copilot
AI
Apr 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logging the full generated JSON (outStr) at INFO level can be noisy and potentially large, impacting storage/performance on embedded targets. Consider logging only the selected category and output length (or downgrade to DEBUG).
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -191,6 +191,8 @@ | |||
| #define RDK_REMOTE_DEBUGGER_ENABLE "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.Enable" | ||||
| #define RDK_REMOTE_DEBUGGER_ISSUETYPE "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.IssueType" | ||||
| #define RDK_REMOTE_DEBUGGER_WEBCFGDATA "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.WebCfgData" | ||||
| #define RDK_REMOTE_DEBUGGER_SET_PROFILE_DATA "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.setProfileData" | ||||
| #define RDK_REMOTE_DEBUGGER_GET_PROFILE_DATA "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.getProfileData" | ||||
| #endif | ||||
|
|
||||
| /* Profile: X_RDKCENTRAL-COM_RFC.Feature.RebootStop */ | ||||
|
|
@@ -274,6 +276,11 @@ class hostIf_DeviceInfo { | |||
| static XBSStore *m_bsStore; | ||||
| static string m_xrPollingAction; | ||||
|
|
||||
| #ifdef USE_REMOTE_DEBUGGER | ||||
| static string m_rdkRemoteDebuggerProfileCategory; | ||||
| static string m_rdkRemoteDebuggerProfileData; | ||||
|
||||
| static string m_rdkRemoteDebuggerProfileData; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handleGetMsgis dispatching the readWrite parameter...RDKRemoteDebugger.setProfileDataby calling the setter. A GET for this parameter would unexpectedly mutate internal state (e.g., setting the category to an empty string) and bypass the normal SET path. This branch should be removed fromhandleGetMsgand handled viahandleSetMsg(it already routes RFC params throughset_xRDKCentralComRFC).