Skip to content

Commit e33aa12

Browse files
authored
RDKEMW-3380 : Evaluate the Deepsleep Scenario for Static and Dynamic method (#123)
* Update rrdIarmEvents.c * Update rrdIarmEvents.c * Update rrdIarmEvents.c * Update rrdIarmEvents.c * Update rrdIarmEvents.c * Update rrdCommon.h * Update rrdIarmEvents.c * Update rrdInterface.h * Update rrdCommon.h * Update rrdRunCmdThread.c * Update rrdRunCmdThread.c * Update rrdRunCmdThread.c * Update rrdDynamic.c * Update rrdJsonParser.c * Update rrdCommon.h * Update rrdIarmEvents.c * Update rrdInterface.h * Update rrdInterface.h * Update rrdIarmEvents.c * Update rrdIarmEvents.c * Update rrdIarmEvents.c * Update rrdRunCmdThread.c * Update rrdRunCmdThread.c * Update rrdRunCmdThread.c * Update rrdIarmEvents.c * Update rrdIarmEvents.c * Update rrdIarmEvents.c * Update rrdJsonParser.c * Update rrdEventProcess.c * Update rrdJsonParser.c * Update rrdJsonParser.c * Update rrdJsonParser.c * Update rrdEventProcess.c * Update rrdCommon.h * Update rrdIarmEvents.c * Update rrdIarmEvents.c * Update rrdIarmEvents.c
1 parent e86dd66 commit e33aa12

File tree

4 files changed

+14
-25
lines changed

4 files changed

+14
-25
lines changed

src/rrdDynamic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ void RRDRdmManagerDownloadRequest(issueNodeData *pissueStructNode, char *dynJSON
219219
{
220220
#ifdef IARMBUS_SUPPORT
221221
if (isDeepSleepAwakeEvent)
222-
strncpy(msgDataString, paramString, msgDataStringSize);
222+
strncpy(msgDataString, paramString, (msgDataStringSize - strlen(RDM_PKG_SUFFIX)));
223223
else
224224
snprintf(msgDataString, msgDataStringSize, "%s%s", RDM_PKG_PREFIX, pissueStructNode->Node);
225225
#else

src/rrdEventProcess.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ static void processIssueType(data_buf *rbuf)
191191
processIssueTypeInStaticProfile(rbuf, pIssueNode);
192192
}
193193
//CID-336989: Resource leak
194-
free(pIssueNode);
195194
}
196195
else
197196
{
@@ -297,16 +296,11 @@ static void processIssueTypeInStaticProfile(data_buf *rbuf, issueNodeData *pIssu
297296
isStaticIssue = findIssueInParsedJSON(pIssueNode, jsonParsed);
298297
if (isStaticIssue)
299298
{
300-
// Issue in Static Profile JSON
301-
// CID 336981: Use after free (USE_AFTER_FREE)
302-
if ( pIssueNode->Node && pIssueNode->subNode )
303-
{
304-
RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: Issue Data Node: %s and Sub-Node: %s found in Static JSON File %s... \n", __FUNCTION__, __LINE__, pIssueNode->Node, pIssueNode->subNode, RRD_JSON_FILE);
305-
// CID 336988: Double free (USE_AFTER_FREE)
306-
if (rbuf)
307-
{
308-
checkIssueNodeInfo(pIssueNode, jsonParsed, rbuf, false, NULL); // sanity Check and Get Command List
309-
}
299+
RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: Issue Data Node: %s and Sub-Node: %s found in Static JSON File %s... \n", __FUNCTION__, __LINE__, pIssueNode->Node, pIssueNode->subNode, RRD_JSON_FILE);
300+
// CID 336988: Double free (USE_AFTER_FREE)
301+
if(rbuf)
302+
{
303+
checkIssueNodeInfo(pIssueNode, jsonParsed, rbuf, false, NULL); // sanity Check and Get Command List
310304
}
311305
}
312306
else

src/rrdIarmEvents.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -144,17 +144,14 @@ int RRD_IARM_subscribe()
144144
void _pwrManagerEventHandler(const PowerController_PowerState_t currentState,
145145
const PowerController_PowerState_t newState, void* userdata)
146146
{
147-
#if !defined(ENABLE_WEBCFG_FEATURE)
148147
data_buf *sbuf = NULL;
149148
int msgLen = strlen(DEEP_SLEEP_STR) + 1;
150-
#endif
151149
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: ...Entering.. currentState =%d, newState = %d\n", __FUNCTION__, __LINE__, currentState, newState);
152150

153151
if ((currentState == POWER_STATE_STANDBY_DEEP_SLEEP &&
154152
newState != POWER_STATE_STANDBY_DEEP_SLEEP))
155153
{
156154
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Received state from Power Manager Current :[%d] New[%d] \n", __FUNCTION__, __LINE__, currentState, newState);
157-
#ifdef ENABLE_WEBCFG_FEATURE
158155
rbusError_t rc = RBUS_ERROR_BUS_ERROR;
159156
rbusValue_t value;
160157
rbusValue_Init(&value);
@@ -166,26 +163,24 @@ void _pwrManagerEventHandler(const PowerController_PowerState_t currentState,
166163
return;
167164
}
168165
RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: Invoking WebCfg Force Sync: %s... \n", __FUNCTION__, __LINE__, RRD_WEBCFG_FORCE_SYNC);
169-
#else
170166
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Copying Message Received to the queue.. \n", __FUNCTION__, __LINE__);
171167
sbuf = (data_buf *)malloc(sizeof(data_buf));
172168
if (!sbuf)
173169
{
174-
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Memory Allocation Failed for EventId %d \n", __FUNCTION__, __LINE__, eventId);
170+
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Memory Allocation Failed for EventId \n", __FUNCTION__, __LINE__);
175171
return;
176172
}
177173

178174
RRD_data_buff_init(sbuf, DEEPSLEEP_EVENT_MSG, RRD_DEEPSLEEP_RDM_DOWNLOAD_PKG_INITIATE);
179175
sbuf->mdata = (char *)malloc(msgLen);
180176
if (!sbuf->mdata)
181177
{
182-
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Memory Allocation Failed for EventId %d \n", __FUNCTION__, __LINE__, eventId);
178+
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Memory Allocation Failed for EventId \n", __FUNCTION__, __LINE__);
183179
RRD_data_buff_deAlloc(sbuf);
184180
return;
185181
}
186182
strncpy((char *)sbuf->mdata, (const char *)DEEP_SLEEP_STR, msgLen);
187183
RRDMsgDeliver(msqid, sbuf);
188-
#endif
189184
}
190185
else
191186
{
@@ -207,10 +202,8 @@ void _pwrManagerEventHandler(const PowerController_PowerState_t currentState,
207202
void _pwrManagerEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len)
208203
{
209204
IARM_Bus_PWRMgr_EventData_t *eventData = NULL;
210-
#if !defined(ENABLE_WEBCFG_FEATURE)
211205
data_buf *sbuf = NULL;
212206
int msgLen = strlen(DEEP_SLEEP_STR) + 1;
213-
#endif
214207
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: ...Entering.. \n", __FUNCTION__, __LINE__);
215208

216209
if (strcmp(owner, IARM_BUS_PWRMGR_NAME) == 0)
@@ -223,7 +216,6 @@ void _pwrManagerEventHandler(const char *owner, IARM_EventId_t eventId, void *da
223216
{
224217
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Event ID found for IARM_BUS_RDK_REMOTE_DEBUGGER_DEEPSLEEP_AWAKE %d \n", __FUNCTION__, __LINE__, eventId);
225218
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Received state from Power Manager Current :[%d] New[%d] \n", __FUNCTION__, __LINE__, eventData->data.state.curState, eventData->data.state.newState);
226-
#ifdef ENABLE_WEBCFG_FEATURE
227219
rbusError_t rc = RBUS_ERROR_BUS_ERROR;
228220
rbusValue_t value;
229221
rbusValue_Init(&value);
@@ -235,7 +227,6 @@ void _pwrManagerEventHandler(const char *owner, IARM_EventId_t eventId, void *da
235227
return;
236228
}
237229
RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: Invoking WebCfg Force Sync: %s... \n", __FUNCTION__, __LINE__, RRD_WEBCFG_FORCE_SYNC);
238-
#else
239230
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Copying Message Received to the queue.. \n", __FUNCTION__, __LINE__);
240231
sbuf = (data_buf *)malloc(sizeof(data_buf));
241232
if (!sbuf)
@@ -254,7 +245,7 @@ void _pwrManagerEventHandler(const char *owner, IARM_EventId_t eventId, void *da
254245
}
255246
strncpy((char *)sbuf->mdata, (const char *)DEEP_SLEEP_STR, msgLen);
256247
RRDMsgDeliver(msqid, sbuf);
257-
#endif
248+
RRD_data_buff_deAlloc(sbuf);
258249
}
259250
else
260251
{
@@ -268,7 +259,6 @@ void _pwrManagerEventHandler(const char *owner, IARM_EventId_t eventId, void *da
268259
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: ...Exit.. \n", __FUNCTION__, __LINE__);
269260
}
270261
#endif
271-
272262
/*
273263
* @function _rdmManagerEventHandler
274264
* @brief Receives the RDM Manager event and sends the value as a message in the message-queue

src/rrdJsonParser.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,11 @@ void checkIssueNodeInfo(issueNodeData *issuestructNode, cJSON *jsoncfg, data_buf
490490
ctime = time (NULL);
491491
ltime = localtime (&ctime);
492492
dlen=snprintf(outdir,BUF_LEN_256,"%s%s-DebugReport-",RRD_OUTPUT_DIR,issuestructNode->Node);
493+
RDK_LOG(RDK_LOG_DEBUG,LOG_REMDEBUG,"[%s:%d]: debug print issuestructNode->Node: %s !!! \n",__FUNCTION__,__LINE__, issuestructNode->Node);
494+
if ((strcmp(issuestructNode->Node, DEEP_SLEEP_STR) == 0)|| (strcmp(issuestructNode->Node, "deepsleep")== 0))
495+
{
496+
isDeepSleepAwakeEventValid = true;
497+
}
493498
strftime (outdir + dlen, sizeof(outdir) - dlen, "%Y-%m-%d-%H-%M-%S", ltime);
494499
RDK_LOG(RDK_LOG_DEBUG,LOG_REMDEBUG,"[%s:%d]: Creating Directory %s for Issue Category to store Output data...\n",__FUNCTION__,__LINE__,outdir);
495500
if (mkdir(outdir,0777) != 0)

0 commit comments

Comments
 (0)