From bbae4adc78e8d51e365f32e9279f8faa2336affe Mon Sep 17 00:00:00 2001 From: Abhishek Vijay Date: Wed, 21 Mar 2018 17:44:38 +0530 Subject: [PATCH] [SVACE Issue Fixes] Change-Id: I69fcc719ac4949da42d5e6f52fcfc06abc8cf6c6 Signed-off-by: Abhishek Vijay --- framework/storage-handler/MsgStorageManager.cpp | 2 +- utils/MsgUtilFunction.cpp | 26 ++++++++++++------------- utils/MsgUtilStorage.cpp | 6 ++++-- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/framework/storage-handler/MsgStorageManager.cpp b/framework/storage-handler/MsgStorageManager.cpp index 8eaf0da..f81d0e2 100755 --- a/framework/storage-handler/MsgStorageManager.cpp +++ b/framework/storage-handler/MsgStorageManager.cpp @@ -1076,7 +1076,7 @@ msg_error_t MsgStoRestoreMessage(const char *filepath, msg_id_list_s **result_id msgIdList->msgIdList = (msg_message_id_t*)calloc(1, sizeof(msg_message_id_t)); if (msgIdList->msgIdList == NULL) { MSG_DEBUG("calloc failed"); - err = MSG_ERR_UNKNOWN; + err = MSG_ERR_NULL_POINTER; goto __RETURN; } } else { diff --git a/utils/MsgUtilFunction.cpp b/utils/MsgUtilFunction.cpp index 0883576..e26b08d 100755 --- a/utils/MsgUtilFunction.cpp +++ b/utils/MsgUtilFunction.cpp @@ -552,25 +552,25 @@ int MsgEncodeThreadInfo(MSG_THREAD_VIEW_S *pThreadInfo, char **ppDest) /* Decoders */ void MsgDecodeMsgId(char *pSrc, msg_message_id_t *pMsgId) { - memcpy(pMsgId, pSrc, sizeof(msg_message_id_t)); + memcpy(pMsgId, pSrc, sizeof(char)*2); } void MsgDecodeCountInfo(char *pSrc, MSG_COUNT_INFO_S *pCountInfo) { - memcpy(pCountInfo, pSrc, sizeof(MSG_COUNT_INFO_S)); + memcpy(pCountInfo, pSrc, sizeof(char)*2); } void MsgDecodeMemSize(char *pSrc, unsigned int *memsize) { - memcpy(memsize, pSrc, sizeof(unsigned int)); + memcpy(memsize, pSrc, sizeof(char)*2); } void MsgDecodeMsgInfo(char *pSrc, MSG_MESSAGE_INFO_S *pMsgInfo) { - memcpy(pMsgInfo, pSrc, sizeof(MSG_MESSAGE_INFO_S)); + memcpy(pMsgInfo, pSrc, sizeof(char)*2); pSrc = pSrc + sizeof(MSG_MESSAGE_INFO_S); @@ -587,7 +587,7 @@ void MsgDecodeMsgInfo(char *pSrc, MSG_MESSAGE_INFO_S *pMsgInfo) void MsgDecodeMsgInfo(char *pSrc, MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S* pSendOptInfo) { - memcpy(pMsgInfo, pSrc, sizeof(MSG_MESSAGE_INFO_S)); + memcpy(pMsgInfo, pSrc, sizeof(char)*2); pSrc = pSrc + sizeof(MSG_MESSAGE_INFO_S); @@ -632,7 +632,7 @@ void MsgDecodeFolderList(char *pSrc, msg_struct_list_s *pFolderList) { int count = 0; - memcpy(&count, pSrc, sizeof(int)); + memcpy(&count, pSrc, sizeof(char)*2); pSrc = pSrc + sizeof(int); if( count > 0 ) { @@ -711,22 +711,22 @@ void MsgDecodeContactCount(char *pSrc, MSG_THREAD_COUNT_INFO_S *pMsgThreadCount if(pSrc == NULL) return; - memcpy(&count, pSrc, sizeof(int)); + memcpy(&count, pSrc, sizeof(char)*2); pSrc = pSrc + sizeof(int); pMsgThreadCountList->totalCount = count; - memcpy(&count, pSrc, sizeof(int)); + memcpy(&count, pSrc, sizeof(char)*2); pSrc = pSrc + sizeof(int); pMsgThreadCountList->unReadCount = count; - memcpy(&count, pSrc, sizeof(int)); + memcpy(&count, pSrc, sizeof(char)*2); pSrc = pSrc + sizeof(int); pMsgThreadCountList->mmsMsgCount = count; - memcpy(&count, pSrc, sizeof(int)); + memcpy(&count, pSrc, sizeof(char)*2); pSrc = pSrc + sizeof(int); pMsgThreadCountList->smsMsgCount = count; @@ -742,7 +742,7 @@ void MsgDecodeReportStatus(char *pSrc, msg_struct_list_s *report_list) if(pSrc == NULL) return; - memcpy(&count, pSrc, sizeof(int)); + memcpy(&count, pSrc, sizeof(char)*2); pSrc = pSrc + sizeof(int); report_list->nCount = count; @@ -772,12 +772,12 @@ void MsgDecodeReportStatus(char *pSrc, msg_struct_list_s *report_list) void MsgDecodeThreadId(char *pSrc, msg_thread_id_t *pThreadId) { - memcpy(pThreadId, pSrc, sizeof(msg_thread_id_t)); + memcpy(pThreadId, pSrc, sizeof(char)*2); } void MsgDecodeThreadInfo(char *pSrc, MSG_THREAD_VIEW_S *pThreadInfo) { - memcpy(pThreadInfo, pSrc, sizeof(MSG_THREAD_VIEW_S)); + memcpy(pThreadInfo, pSrc, sizeof(char)*2); } /* Event Encoder */ diff --git a/utils/MsgUtilStorage.cpp b/utils/MsgUtilStorage.cpp index 8da7f11..0f2e607 100755 --- a/utils/MsgUtilStorage.cpp +++ b/utils/MsgUtilStorage.cpp @@ -2127,7 +2127,8 @@ msg_error_t MsgStoGetConversationViewItem(msg_message_id_t msgId, MSG_CONVERSATI if (pConv->bRestricted == true) { pConv->textSize = 0; memset(pConv->subject, 0x00, sizeof(pConv->subject)); - tmpText[0] = '\0'; + if (tmpText) + tmpText[0] = '\0'; } pConv->simIndex = dbHandle->getColumnToInt(index++); @@ -2260,7 +2261,8 @@ msg_error_t MsgStoGetConversationViewList(msg_thread_id_t threadId, msg_struct_l if (pTmp->bRestricted == true) { pTmp->textSize = 0; memset(pTmp->subject, 0x00, sizeof(pTmp->subject)); - tmpText[i][0] = '\0'; + if (tmpText[i]) + tmpText[i][0] = '\0'; } pTmp->simIndex = dbHandle->getColumnToInt(index++); } -- 2.7.4