From 0b6e40dac047e6b83a8dfcac43efcccc3f1c850e Mon Sep 17 00:00:00 2001 From: biju-vi <151033276+biju-vi@users.noreply.github.com> Date: Wed, 11 Mar 2026 11:22:14 +0000 Subject: [PATCH 1/4] RDKB-63310 - Fix IDM coverity issue (#12) RDKB-63310 - Fix IDM Coverity report issues LTE-3039: IDM is stuck in XLE causing XB to not discover Remote Device Reason for change: Exit from loop if socket is not usable Test Procedure: NA Risks: Low Signed-off-by: biju.vijayanindiradevi@sky.uk LTE-3039: IDM is stuck in XLE causing XB to not discover Remote Device Reason for change: Exit from loop if socket is not usable Test Procedure: NA Risks: Low Signed-off-by: biju.vijayanindiradevi@sky.uk --- source/InterDeviceManager/Idm_msg_process.c | 34 ++++++++++++++------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/source/InterDeviceManager/Idm_msg_process.c b/source/InterDeviceManager/Idm_msg_process.c index 6cc17c8..3267b7f 100644 --- a/source/InterDeviceManager/Idm_msg_process.c +++ b/source/InterDeviceManager/Idm_msg_process.c @@ -451,14 +451,14 @@ char* IDM_Incoming_FT_Response(connection_info_t* conn_info,payload_t* payload) if( pidmDmlInfo == NULL ) { CcspTraceError(("%s:%d DmlInfo is NULL\n",__FUNCTION__,__LINE__)); - free(req); + free(req); return FT_ERROR; } if(total_bytes > (pidmDmlInfo->stRemoteInfo.max_file_size)) { CcspTraceError(("%s:%d transfer file size exceeded on self device compared to %d configured value\n",__FUNCTION__,__LINE__,(pidmDmlInfo->stRemoteInfo.max_file_size))); IdmMgrDml_GetConfigData_release(pidmDmlInfo); - free(req); + free(req); return FT_INVALID_FILE_SIZE; } IdmMgrDml_GetConfigData_release(pidmDmlInfo); @@ -473,17 +473,17 @@ char* IDM_Incoming_FT_Response(connection_info_t* conn_info,payload_t* payload) ERR_CHK(rc); if((!ind) && (rc == EOK)) { - free(req); + free(req); return FT_INVALID_DST_PATH; } rc = strcmp_s(FT_TMP,strlen(FT_TMP),tok,&ind); ERR_CHK(rc); if((!ind) && (rc == EOK)) { - free(req); + free(req); return FT_INVALID_DST_PATH; } - free(req); + free(req); return FT_NOT_WRITABLE_PATH; } else{ @@ -492,23 +492,23 @@ char* IDM_Incoming_FT_Response(connection_info_t* conn_info,payload_t* payload) { fclose(fptr); CcspTraceError(("malloc failed to allocate memory\n")); - free(req); + free(req); return FT_ERROR; } while(lengthenc.ssl != NULL){ - bytes = SSL_read(conn_info->enc.ssl, buf, total_bytes-bytes); + bytes = SSL_read(conn_info->enc.ssl, buf, total_bytes - length); } else{ CcspTraceError(("%s:%d ssl session is null\n",__FUNCTION__,__LINE__)); fclose(fptr); free(buf); - free(req); + free(req); return FT_ERROR; } #else - bytes = read( conn_info->conn , buf, total_bytes-bytes); + bytes = read( conn_info->conn , buf, total_bytes - length); #endif CcspTraceInfo(("bytes transfered : %d\n",bytes)); if(bytes > 0){ @@ -517,6 +517,8 @@ char* IDM_Incoming_FT_Response(connection_info_t* conn_info,payload_t* payload) } else{ CcspTraceError(("(%s:%d) Data encryption failed (Err: %d)\n", __FUNCTION__, __LINE__,bytes)); + // Exit from tight loop if read socket is not usable or there is no data to read + break; } } if(buf){ @@ -525,12 +527,15 @@ char* IDM_Incoming_FT_Response(connection_info_t* conn_info,payload_t* payload) } fclose(fptr); free(req); - return FT_SUCCESS; } else { CcspTraceError(("%s:%d payload is null\n",__FUNCTION__, __LINE__)); } + if(length > 0 ) + { + return FT_SUCCESS; + } return FT_ERROR; } @@ -876,6 +881,8 @@ char* IDM_SFT_receive(connection_info_t* conn_info,void* payload) } else{ CcspTraceError(("(%s:%d) Data encryption failed (Err: %d)\n", __FUNCTION__, __LINE__,bytes)); + //Exit from tight loop if read socket is not usable or there is no data to read + break; } } if(buf){ @@ -890,7 +897,12 @@ char* IDM_SFT_receive(connection_info_t* conn_info,void* payload) IdmMgrDml_GetConfigData_release(pidmDmlInfo); return FT_ERROR; } - return FT_SUCCESS; + if(length > 0 ) + { + return FT_SUCCESS; + } + return FT_ERROR; + } int IDM_Incoming_Request_handler(payload_t * payload) From 6c095da4cbb28fbeef42fb1f735c6e1c43acdbf8 Mon Sep 17 00:00:00 2001 From: biju-vi <151033276+biju-vi@users.noreply.github.com> Date: Wed, 11 Mar 2026 11:22:14 +0000 Subject: [PATCH 2/4] LTE-3039: IDM is stuck in XLE causing XB to not discover Remote Device Reason for change: Exit from loop if socket is not usable Test Procedure: NA Risks: Low Signed-off-by: biju.vijayanindiradevi@sky.uk --- source/InterDeviceManager/Idm_msg_process.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/InterDeviceManager/Idm_msg_process.c b/source/InterDeviceManager/Idm_msg_process.c index 3267b7f..801f127 100644 --- a/source/InterDeviceManager/Idm_msg_process.c +++ b/source/InterDeviceManager/Idm_msg_process.c @@ -532,7 +532,7 @@ char* IDM_Incoming_FT_Response(connection_info_t* conn_info,payload_t* payload) { CcspTraceError(("%s:%d payload is null\n",__FUNCTION__, __LINE__)); } - if(length > 0 ) + if(length == total_bytes ) { return FT_SUCCESS; } @@ -861,7 +861,7 @@ char* IDM_SFT_receive(connection_info_t* conn_info,void* payload) while(lengthenc.ssl != NULL){ - bytes = SSL_read(conn_info->enc.ssl, buf, total_bytes-bytes); + bytes = SSL_read(conn_info->enc.ssl, buf, total_bytes - length); } else{ CcspTraceError(("%s:%d ssl session is null\n",__FUNCTION__,__LINE__)); @@ -872,7 +872,7 @@ char* IDM_SFT_receive(connection_info_t* conn_info,void* payload) return FT_ERROR; } #else - bytes = read( conn_info->conn , buf, total_bytes-bytes); + bytes = read( conn_info->conn , buf, total_bytes - length); #endif CcspTraceInfo(("bytes transfered : %d\n",bytes)); if(bytes > 0){ @@ -897,7 +897,7 @@ char* IDM_SFT_receive(connection_info_t* conn_info,void* payload) IdmMgrDml_GetConfigData_release(pidmDmlInfo); return FT_ERROR; } - if(length > 0 ) + if(length == total_bytes ) { return FT_SUCCESS; } From 2a1ba7de52bb96c7c1f04e7fc85dba842f44cad8 Mon Sep 17 00:00:00 2001 From: biju-vi <151033276+biju-vi@users.noreply.github.com> Date: Wed, 11 Mar 2026 11:22:14 +0000 Subject: [PATCH 3/4] LTE-3039: IDM is stuck in XLE causing XB to not discover Remote Device Reason for change: Exit from loop if socket is not usable Test Procedure: NA Risks: Low Signed-off-by: biju.vijayanindiradevi@sky.uk --- source/InterDeviceManager/Idm_msg_process.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/InterDeviceManager/Idm_msg_process.c b/source/InterDeviceManager/Idm_msg_process.c index 801f127..c84b08f 100644 --- a/source/InterDeviceManager/Idm_msg_process.c +++ b/source/InterDeviceManager/Idm_msg_process.c @@ -531,11 +531,14 @@ char* IDM_Incoming_FT_Response(connection_info_t* conn_info,payload_t* payload) else { CcspTraceError(("%s:%d payload is null\n",__FUNCTION__, __LINE__)); + return FT_ERROR; } if(length == total_bytes ) { return FT_SUCCESS; } + // delete a truncated file in case there was an error in the middle + remove(req->output_location) return FT_ERROR; } @@ -901,6 +904,7 @@ char* IDM_SFT_receive(connection_info_t* conn_info,void* payload) { return FT_SUCCESS; } + remove(Data->param_name); return FT_ERROR; } From acb88a16da8d7bb58af19c534b17d9b85d85f2fe Mon Sep 17 00:00:00 2001 From: biju-vi <151033276+biju-vi@users.noreply.github.com> Date: Wed, 11 Mar 2026 11:22:14 +0000 Subject: [PATCH 4/4] LTE-3039: IDM is stuck in XLE causing XB to not discover Remote Device Reason for change: Exit from loop if socket is not usable Test Procedure: NA Risks: Low Signed-off-by: biju.vijayanindiradevi@sky.uk --- source/InterDeviceManager/Idm_msg_process.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/source/InterDeviceManager/Idm_msg_process.c b/source/InterDeviceManager/Idm_msg_process.c index c84b08f..76a7f5f 100644 --- a/source/InterDeviceManager/Idm_msg_process.c +++ b/source/InterDeviceManager/Idm_msg_process.c @@ -526,6 +526,13 @@ char* IDM_Incoming_FT_Response(connection_info_t* conn_info,payload_t* payload) } } fclose(fptr); + if(length < total_bytes) + { + // remove partially filled file + remove(req->output_location) + free(req); + return FT_ERROR; + } free(req); } else @@ -533,13 +540,7 @@ char* IDM_Incoming_FT_Response(connection_info_t* conn_info,payload_t* payload) CcspTraceError(("%s:%d payload is null\n",__FUNCTION__, __LINE__)); return FT_ERROR; } - if(length == total_bytes ) - { - return FT_SUCCESS; - } - // delete a truncated file in case there was an error in the middle - remove(req->output_location) - return FT_ERROR; + return FT_SUCCESS; } int IDM_Incoming_Response_handler(payload_t * payload)