svace issues fixed 03/123303/3
authorKyeonghun Lee <kh9090.lee@samsung.com>
Wed, 5 Apr 2017 07:21:54 +0000 (16:21 +0900)
committerKyeonghun Lee <kh9090.lee@samsung.com>
Wed, 12 Apr 2017 09:43:24 +0000 (18:43 +0900)
Change-Id: I1064b3bd91f33df27aaecc1a85dd3ec17ddde680
Signed-off-by: Kyeonghun Lee <kh9090.lee@samsung.com>
framework/storage-handler/MsgStorageManager.cpp
plugin/mms_plugin/MmsPluginInternal.cpp
plugin/mms_plugin/MmsPluginMessage.cpp
plugin/sms_plugin/SmsPluginSetting.cpp
plugin/sms_plugin/SmsPluginStorage.cpp
utils/MsgUtilFunction.cpp

index fd33ddb..1590363 100755 (executable)
@@ -978,7 +978,7 @@ msg_error_t MsgStoRestoreMessage(const char *filepath, msg_id_list_s **result_id
 
                                                msgInfo.bTextSms = false;
 
-                                               char fileName[MAX_COMMON_INFO_SIZE+1];
+                                               char fileName[MSG_FILENAME_LEN_MAX+1];
                                                memset(fileName, 0x00, sizeof(fileName));
 
                                                if (MsgCreateFileName(fileName) == false) {
index 299e57e..a236e6b 100755 (executable)
@@ -547,6 +547,17 @@ void MmsPluginInternal::processSendConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTranQEn
 }
 
 #if 1
+void __fillAddressInfo(MSG_ADDRESS_INFO_S *addressInfo, const char *addressVal)
+{
+       strncpy(addressInfo->addressVal, addressVal, MAX_ADDRESS_VAL_LEN);
+       addressInfo->recipientType = MSG_RECIPIENTS_TYPE_TO;
+       if (MmsAddrUtilCheckEmailAddress(addressInfo->addressVal)) {
+               addressInfo->addressType = MSG_ADDRESS_TYPE_EMAIL;
+       } else {
+               addressInfo->addressType = MSG_ADDRESS_TYPE_PLMN;
+       }
+}
+
 void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTranQEntity *pRequest, char *pRetrievedFilePath)
 {
        MSG_BEGIN();
@@ -649,85 +660,42 @@ void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTra
        pMsgInfo->nAddressCnt = addr_cnt;
        pMsgInfo->addressList = tmp_addr_info;
 
-       if (mmsHeader.pFrom) {
-               MSG_DEBUG("FROM : [%s]", mmsHeader.pFrom->szAddr);
-               /* From */
-               strncpy(pMsgInfo->addressList[0].addressVal, mmsHeader.pFrom->szAddr, MAX_ADDRESS_VAL_LEN);
-               if (MmsAddrUtilCheckEmailAddress(pMsgInfo->addressList[0].addressVal)) {
-                       pMsgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_EMAIL;
-               } else {
-                       pMsgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_PLMN;
+       if (recipients_addr_info != NULL && pMsgInfo->addressList != NULL) {
+               if (mmsHeader.pFrom) {
+                       MSG_DEBUG("FROM : [%s]", mmsHeader.pFrom->szAddr);
+                       /* From */
+                       __fillAddressInfo(&(pMsgInfo->addressList[0]), mmsHeader.pFrom->szAddr);
+                       __fillAddressInfo(&recipients_addr_info[0], mmsHeader.pFrom->szAddr);
                }
 
-               strncpy(recipients_addr_info[0].addressVal, mmsHeader.pFrom->szAddr, MAX_ADDRESS_VAL_LEN);
-               if (MmsAddrUtilCheckEmailAddress(pMsgInfo->addressList[0].addressVal)) {
-                       recipients_addr_info[0].addressType = MSG_ADDRESS_TYPE_EMAIL;
-               } else {
-                       recipients_addr_info[0].addressType = MSG_ADDRESS_TYPE_PLMN;
-               }
-       }
-
-       int addr_idx = 0;
-       int recipients_idx = 0;
-       if (mmsHeader.pTo) {
-               MsgHeaderAddress *iter = mmsHeader.pTo;
-               while (iter) {
-                       addr_idx++;
-                       MSG_DEBUG("TO : [%s]", mmsHeader.pTo->szAddr);
-                       /* To */
-                       if (normal_msisdn == NULL || normal_msisdn[0] == '\0' || !g_str_has_suffix(iter->szAddr, normal_msisdn)) {
-                               strncpy(pMsgInfo->addressList[addr_idx].addressVal, iter->szAddr, MAX_ADDRESS_VAL_LEN);
-                               pMsgInfo->addressList[addr_idx].recipientType = MSG_RECIPIENTS_TYPE_TO;
-                               if (MmsAddrUtilCheckEmailAddress(pMsgInfo->addressList[addr_idx].addressVal)) {
-                                       pMsgInfo->addressList[addr_idx].addressType = MSG_ADDRESS_TYPE_EMAIL;
-                               } else {
-                                       pMsgInfo->addressList[addr_idx].addressType = MSG_ADDRESS_TYPE_PLMN;
+               int addr_idx = 0;
+               int recipients_idx = 0;
+               if (mmsHeader.pTo) {
+                       MsgHeaderAddress *iter = mmsHeader.pTo;
+                       while (iter) {
+                               MSG_DEBUG("TO : [%s]", iter->szAddr);
+                               /* To */
+                               if (normal_msisdn == NULL || normal_msisdn[0] == '\0' || !g_str_has_suffix(iter->szAddr, normal_msisdn)) {
+                                       __fillAddressInfo(&(pMsgInfo->addressList[++addr_idx]), iter->szAddr);
                                }
-                       } else {
-                               addr_idx--;
-                       }
+                               __fillAddressInfo(&recipients_addr_info[++recipients_idx], iter->szAddr);
 
-                       recipients_idx++;
-                       strncpy(recipients_addr_info[recipients_idx].addressVal, iter->szAddr, MAX_ADDRESS_VAL_LEN);
-                       recipients_addr_info[recipients_idx].recipientType = MSG_RECIPIENTS_TYPE_TO;
-                       if (MmsAddrUtilCheckEmailAddress(recipients_addr_info[recipients_idx].addressVal)) {
-                               recipients_addr_info[recipients_idx].addressType = MSG_ADDRESS_TYPE_EMAIL;
-                       } else {
-                               recipients_addr_info[recipients_idx].addressType = MSG_ADDRESS_TYPE_PLMN;
+                               iter = iter->pNext;
                        }
-
-                       iter = iter->pNext;
                }
-       }
 
-       if (mmsHeader.pCc) {
-               MsgHeaderAddress *iter = mmsHeader.pCc;
-               while (iter) {
-                       addr_idx++;
-                       MSG_DEBUG("CC : [%s]", mmsHeader.pCc->szAddr);
-                       /* Cc */
-                       if (normal_msisdn == NULL || normal_msisdn[0] == '\0' || !g_str_has_suffix(iter->szAddr, normal_msisdn)) {
-                               strncpy(pMsgInfo->addressList[addr_idx].addressVal, iter->szAddr, MAX_ADDRESS_VAL_LEN);
-                               pMsgInfo->addressList[addr_idx].recipientType = MSG_RECIPIENTS_TYPE_CC;
-                               if (MmsAddrUtilCheckEmailAddress(pMsgInfo->addressList[addr_idx].addressVal)) {
-                                       pMsgInfo->addressList[addr_idx].addressType = MSG_ADDRESS_TYPE_EMAIL;
-                               } else {
-                                       pMsgInfo->addressList[addr_idx].addressType = MSG_ADDRESS_TYPE_PLMN;
+               if (mmsHeader.pCc) {
+                       MsgHeaderAddress *iter = mmsHeader.pCc;
+                       while (iter) {
+                               MSG_DEBUG("CC : [%s]", iter->szAddr);
+                               /* Cc */
+                               if (normal_msisdn == NULL || normal_msisdn[0] == '\0' || !g_str_has_suffix(iter->szAddr, normal_msisdn)) {
+                                       __fillAddressInfo(&(pMsgInfo->addressList[++addr_idx]), iter->szAddr);
                                }
-                       } else {
-                               addr_idx--;
-                       }
+                               __fillAddressInfo(&recipients_addr_info[++recipients_idx], iter->szAddr);
 
-                       recipients_idx++;
-                       strncpy(recipients_addr_info[recipients_idx].addressVal, iter->szAddr, MAX_ADDRESS_VAL_LEN);
-                       recipients_addr_info[recipients_idx].recipientType = MSG_RECIPIENTS_TYPE_CC;
-                       if (MmsAddrUtilCheckEmailAddress(recipients_addr_info[recipients_idx].addressVal)) {
-                               recipients_addr_info[recipients_idx].addressType = MSG_ADDRESS_TYPE_EMAIL;
-                       } else {
-                               recipients_addr_info[recipients_idx].addressType = MSG_ADDRESS_TYPE_PLMN;
+                               iter = iter->pNext;
                        }
-
-                       iter = iter->pNext;
                }
        }
 
index 3f4b4a3..44b633b 100755 (executable)
@@ -386,9 +386,6 @@ msg_error_t MmsMakeMultipartThumbnailInfo(MMS_MULTIPART_DATA_S *pMultipart, char
        char *pszExt = NULL;
        char *pszOrgFileName = NULL;
 
-       memset(szFileName, 0x00, MSG_FILENAME_LEN_MAX+1);
-       memset(thumbPath, 0x00, MSG_FILEPATH_LEN_MAX);
-
        MSG_SEC_DEBUG("drm type = %d, %s", pMultipart->drmType, pMultipart->szFilePath);
 
        if (pMultipart->drmType == MSG_DRM_TYPE_NONE) {
@@ -419,6 +416,7 @@ msg_error_t MmsMakeMultipartThumbnailInfo(MMS_MULTIPART_DATA_S *pMultipart, char
 
                if (MakeThumbnail(pMultipart->szFilePath, thumbPath) == true) {
                        memcpy(thumbnail_path, &thumbPath, strlen(thumbPath));
+                       thumbnail_path[strlen(thumbPath)] = '\0';
                        MSG_SEC_DEBUG("Generated thumbnail: %s ", thumbnail_path);
                        return MSG_SUCCESS;
                } else {
index 84eaa7f..9ec7222 100755 (executable)
@@ -368,7 +368,8 @@ void SmsPluginSetting::SimRefreshCb(TapiHandle *handle)
        pthread_t thd;
 
        if (pthread_create(&thd, NULL, &init_config_data, handle) < 0) {
-               MSG_DEBUG("pthread_create() error");
+               MSG_ERR("pthread_create() error");
+               return;
        }
 
        pthread_detach(thd);
@@ -1936,9 +1937,9 @@ void SmsPluginSetting::setSimChangeStatus(TapiHandle *handle, bool bInitializing
                        MSG_DEBUG("calling initSimInfo");
                        if (pthread_create(&thd, NULL, &initSimInfo, handle) < 0) {
                                MSG_DEBUG("pthread_create() error");
+                       } else {
+                               pthread_detach(thd);
                        }
-                       pthread_detach(thd);
-
                } else {
                        MSG_DEBUG("SIM init was already done!");
                }
index 5fd8645..492453a 100755 (executable)
@@ -693,8 +693,8 @@ msg_error_t SmsPluginStorage::addClass2Message(MSG_MESSAGE_INFO_S *pMsgInfo)
 
        if (pthread_create(&thd, NULL, &class2_thread, (void *)&msgInfo) < 0)
                MSG_DEBUG("pthread_create() error");
-
-       pthread_detach(thd);
+       else
+               pthread_detach(thd);
 
 #if 0
        err = SmsPluginSimMsg::instance()->saveClass2Message(pMsgInfo);
index 392e088..0883576 100755 (executable)
@@ -1119,6 +1119,7 @@ msg_error_t MsgMakeSortRule(const MSG_SORT_RULE_S *pSortRule, char *pSqlSort)
        }
 
        memcpy(pSqlSort, sql, strlen(sql));
+       pSqlSort[strlen(sql)] = '\0';
 
        return MSG_SUCCESS;
 }
@@ -1286,14 +1287,6 @@ void* _msg_launch_app(void *data)
 
 msg_error_t msg_launch_app(const char *app_id, bundle *bundle_data)
 {
-       msg_launch_app_data *data = (msg_launch_app_data *)calloc(1, sizeof(msg_launch_app_data));
-       if (data == NULL) {
-               MSG_ERR("Memory alloc failed!");
-               return MSG_ERR_MEMORY_ERROR;
-       }
-
-       data->app_id = g_strdup(app_id);
-       data->bundle_data = bundle_dup(bundle_data);
        pthread_t thd;
        pthread_attr_t attr;
 
@@ -1307,6 +1300,15 @@ msg_error_t msg_launch_app(const char *app_id, bundle *bundle_data)
                return MSG_ERR_UNKNOWN;
        }
 
+       msg_launch_app_data *data = (msg_launch_app_data *)calloc(1, sizeof(msg_launch_app_data));
+       if (data == NULL) {
+               MSG_ERR("Memory alloc failed!");
+               return MSG_ERR_MEMORY_ERROR;
+       }
+
+       data->app_id = g_strdup(app_id);
+       data->bundle_data = bundle_dup(bundle_data);
+
        if (pthread_create(&thd, &attr, &_msg_launch_app, data) < 0) {
                MSG_ERR("pthread_create() error");
        }