From: Abhimanyu Swami Date: Fri, 18 Dec 2020 09:58:23 +0000 (+0530) Subject: SVACE issue fix X-Git-Tag: submit/tizen/20201223.102630^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2ecadb061a7cd75bd15aad72e349297625f76a58;p=platform%2Fcore%2Fmessaging%2Fmsg-service.git SVACE issue fix Change-Id: Idec108f93851ed5ebdbb4138f739b00d34b8bc9e Signed-off-by: Abhimanyu Swami --- diff --git a/framework/storage-handler/MsgStorageFolder.cpp b/framework/storage-handler/MsgStorageFolder.cpp index 1688fec..bf12ef3 100755 --- a/framework/storage-handler/MsgStorageFolder.cpp +++ b/framework/storage-handler/MsgStorageFolder.cpp @@ -133,6 +133,11 @@ msg_error_t MsgStoGetFolderList(msg_struct_list_s *pFolderList) pFolderList->msg_struct_info = (msg_struct_t *)calloc(rowCnt, sizeof(MSG_FOLDER_INFO_S *)); + if (pFolderList->msg_struct_info == NULL){ + dbHandle->freeTable(); + return MSG_ERR_NULL_POINTER; + } + msg_struct_s* pTmp = NULL; for (int i = 0; i < rowCnt; i++) { diff --git a/plugin/sms_plugin/3gpp2/Sms3gpp2Codec.cpp b/plugin/sms_plugin/3gpp2/Sms3gpp2Codec.cpp index 7ac659f..c00684c 100755 --- a/plugin/sms_plugin/3gpp2/Sms3gpp2Codec.cpp +++ b/plugin/sms_plugin/3gpp2/Sms3gpp2Codec.cpp @@ -2070,15 +2070,20 @@ int Sms3gpp2MsgCodec::decodeAbsTime(const unsigned char *p_pkg_str, sms_3gpp2_ti int Sms3gpp2MsgCodec::encodeUserData(const unsigned char* src, unsigned char *dest, int src_size) { - int i, j; + int i, j = 0; int shift = 0; unsigned char *tmp = (unsigned char *)calloc(1, src_size+1); + + if (tmp == NULL){ + MSG_ERR("failed to allocate memory"); + goto END; + } + for (i = 0; i < src_size; i++) { tmp[i] = src[i] << 1; } - j = 0; for (i = 0; i < src_size; i++) { shift = j % 7; dest[j++] = (tmp[i] << shift) + (tmp[i+1] >> (7-shift)); @@ -2092,6 +2097,7 @@ int Sms3gpp2MsgCodec::encodeUserData(const unsigned char* src, unsigned char *de tmp = NULL; } +END: return j; } diff --git a/utils/MsgUtilStorage.cpp b/utils/MsgUtilStorage.cpp index 04d6d76..1ac8b23 100755 --- a/utils/MsgUtilStorage.cpp +++ b/utils/MsgUtilStorage.cpp @@ -654,6 +654,11 @@ msg_error_t MsgStoGetAddressByConvId(MsgDbHandler *pDbHandle, msg_thread_id_t co pAddrlist->msg_struct_info = (msg_struct_t *)calloc(rowCnt, sizeof(msg_struct_t)); + if (pAddrlist->msg_struct_info == NULL){ + pDbHandle->freeTable(); + return MSG_ERR_NULL_POINTER; + } + for (int i = 0; i < rowCnt; i++) { pAddrlist->msg_struct_info[i] = (msg_struct_t)new msg_struct_s; pTmp = (msg_struct_s *)pAddrlist->msg_struct_info[i]; @@ -1753,6 +1758,11 @@ msg_error_t MsgStoGetThreadViewList(const MSG_SORT_RULE_S *pSortRule, msg_struct pThreadViewList->msg_struct_info = (msg_struct_t *)calloc(rowCnt, sizeof(msg_struct_t)); + if (pThreadViewList->msg_struct_info == NULL){ + dbHandle->freeTable(); + return MSG_ERR_NULL_POINTER; + } + MSG_THREAD_VIEW_S *pTmp = NULL; msg_struct_s *thread_t = NULL; @@ -2220,6 +2230,12 @@ msg_error_t MsgStoGetConversationViewList(msg_thread_id_t threadId, msg_struct_l MSG_DEBUG("pConvViewList->nCount [%d]", pConvViewList->nCount); pConvViewList->msg_struct_info = (msg_struct_t *)calloc(rowCnt, sizeof(msg_struct_t)); + + if (pConvViewList->msg_struct_info = NULL){ + dbHandle->freeTable(); + return MSG_ERR_NULL_POINTER; + } + memset(pConvViewList->msg_struct_info, 0x00, sizeof(msg_struct_t) * rowCnt); msg_struct_s *conv = NULL; @@ -2531,6 +2547,11 @@ msg_error_t MsgStoGetRejectMsgList(const char *pNumber, msg_struct_list_s *pReje pRejectMsgList->msg_struct_info = (msg_struct_t *)calloc(rowCnt, sizeof(MSG_REJECT_MSG_INFO_S *)); + if (pRejectMsgList->msg_struct_info == NULL){ + dbHandle->freeTable(); + return MSG_ERR_NULL_POINTER; + } + msg_struct_s* pTmp = NULL; for (int i = 0; i < rowCnt; i++) { diff --git a/utils/MsgVMessage.cpp b/utils/MsgVMessage.cpp index ba17cdd..36d4fdb 100755 --- a/utils/MsgVMessage.cpp +++ b/utils/MsgVMessage.cpp @@ -627,6 +627,8 @@ static inline int __msgsvc_vmsg_add_folding(char **buf, int *buf_size, int buf_l bool encode_64 = false; buf_copy = (char *)calloc(1, *buf_size); + if (buf_copy == NULL) + return -1; s = *buf; r = buf_copy;