SVACE issue fix 88/254288/1 accepted/tizen/unified/20210226.131825 submit/tizen/20210226.052208
authorAbhimanyu Swami <abhimanyu1.s@samsung.com>
Thu, 25 Feb 2021 12:46:12 +0000 (18:16 +0530)
committerAbhimanyu Swami <abhimanyu1.s@samsung.com>
Thu, 25 Feb 2021 12:46:24 +0000 (18:16 +0530)
Change-Id: I8565465f0b4584df45bd62a2f94839a64316aae4
Signed-off-by: Abhimanyu Swami <abhimanyu1.s@samsung.com>
framework/storage-handler/MsgStorageFolder.cpp
plugin/sms_plugin/3gpp2/Sms3gpp2Codec.cpp
utils/MsgUtilStorage.cpp
utils/MsgVMessage.cpp

index 1688fec..bf12ef3 100755 (executable)
@@ -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++) {
index 7ac659f..5a92d5b 100755 (executable)
@@ -2070,7 +2070,7 @@ 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);
@@ -2078,7 +2078,11 @@ int Sms3gpp2MsgCodec::encodeUserData(const unsigned char* src, unsigned char *de
                tmp[i] = src[i] << 1;
        }
 
-       j = 0;
+       if (tmp == NULL){
+               MSG_ERR("failed to allocate memory");
+               goto END;
+       }
+
        for (i = 0; i < src_size; i++) {
                shift = j % 7;
                dest[j++] = (tmp[i] << shift) + (tmp[i+1] >> (7-shift));
@@ -2092,6 +2096,7 @@ int Sms3gpp2MsgCodec::encodeUserData(const unsigned char* src, unsigned char *de
                tmp = NULL;
        }
 
+END:
        return j;
 }
 
index 04d6d76..8dfcb78 100755 (executable)
@@ -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;
 
@@ -2222,6 +2232,11 @@ msg_error_t MsgStoGetConversationViewList(msg_thread_id_t threadId, msg_struct_l
        pConvViewList->msg_struct_info = (msg_struct_t *)calloc(rowCnt, sizeof(msg_struct_t));
        memset(pConvViewList->msg_struct_info, 0x00, sizeof(msg_struct_t) * rowCnt);
 
+       if (pConvViewList->msg_struct_info == NULL){
+               dbHandle->freeTable();
+               return MSG_ERR_NULL_POINTER;
+       }
+
        msg_struct_s *conv = NULL;
        MSG_CONVERSATION_VIEW_S *pTmp = NULL;
 
@@ -2533,6 +2548,11 @@ msg_error_t MsgStoGetRejectMsgList(const char *pNumber, msg_struct_list_s *pReje
 
        msg_struct_s* pTmp = NULL;
 
+       if (pRejectMsgList->msg_struct_info == NULL){
+               dbHandle->freeTable();
+               return MSG_ERR_NULL_POINTER;
+       }
+
        for (int i = 0; i < rowCnt; i++) {
                pRejectMsgList->msg_struct_info[i] = (msg_struct_t)new msg_struct_s;
 
index ba17cdd..39ba518 100755 (executable)
@@ -628,6 +628,9 @@ static inline int __msgsvc_vmsg_add_folding(char **buf, int *buf_size, int buf_l
 
        buf_copy = (char *)calloc(1, *buf_size);
 
+       if (buf_copy == NULL)
+               return -1;
+
        s = *buf;
        r = buf_copy;
        len = result_len = 0;