Skip to content
Closed
Changes from all commits
Commits
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
45 changes: 31 additions & 14 deletions source/InterDeviceManager/Idm_msg_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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{
Expand All @@ -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(length<total_bytes){
#ifndef IDM_DEBUG
if(conn_info->enc.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){
Expand All @@ -517,21 +517,30 @@ 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;
}
Comment thread
biju-vi marked this conversation as resolved.
}
if(buf){
free(buf);
}
}
fclose(fptr);
if(length < total_bytes)
{
// remove partially filled file
remove(req->output_location)
free(req);
return FT_ERROR;
}
free(req);
return FT_SUCCESS;
}
else
{
CcspTraceError(("%s:%d payload is null\n",__FUNCTION__, __LINE__));
return FT_ERROR;
}
return FT_ERROR;
return FT_SUCCESS;
}

int IDM_Incoming_Response_handler(payload_t * payload)
Expand Down Expand Up @@ -856,7 +865,7 @@ char* IDM_SFT_receive(connection_info_t* conn_info,void* payload)
while(length<total_bytes){
#ifndef IDM_DEBUG
if(conn_info->enc.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__));
Expand All @@ -867,7 +876,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){
Expand All @@ -876,6 +885,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){
Expand All @@ -890,7 +901,13 @@ char* IDM_SFT_receive(connection_info_t* conn_info,void* payload)
IdmMgrDml_GetConfigData_release(pidmDmlInfo);
return FT_ERROR;
}
return FT_SUCCESS;
if(length == total_bytes )
{
return FT_SUCCESS;
}
remove(Data->param_name);
return FT_ERROR;

}

int IDM_Incoming_Request_handler(payload_t * payload)
Expand Down
Loading