From 5cc914592e94ad2e9fd63105d6e77af6e10ae07b Mon Sep 17 00:00:00 2001 From: Kyeonghun Lee Date: Wed, 5 Apr 2017 16:21:54 +0900 Subject: [PATCH] svace issues fixed Change-Id: I1064b3bd91f33df27aaecc1a85dd3ec17ddde680 Signed-off-by: Kyeonghun Lee --- framework/storage-handler/MsgStorageManager.cpp | 2 +- plugin/mms_plugin/MmsPluginInternal.cpp | 106 +++++++++--------------- plugin/mms_plugin/MmsPluginMessage.cpp | 4 +- plugin/sms_plugin/SmsPluginSetting.cpp | 7 +- plugin/sms_plugin/SmsPluginStorage.cpp | 4 +- utils/MsgUtilFunction.cpp | 18 ++-- 6 files changed, 55 insertions(+), 86 deletions(-) diff --git a/framework/storage-handler/MsgStorageManager.cpp b/framework/storage-handler/MsgStorageManager.cpp index fd33ddb..1590363 100755 --- a/framework/storage-handler/MsgStorageManager.cpp +++ b/framework/storage-handler/MsgStorageManager.cpp @@ -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) { diff --git a/plugin/mms_plugin/MmsPluginInternal.cpp b/plugin/mms_plugin/MmsPluginInternal.cpp index 299e57e..a236e6b 100755 --- a/plugin/mms_plugin/MmsPluginInternal.cpp +++ b/plugin/mms_plugin/MmsPluginInternal.cpp @@ -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; } } diff --git a/plugin/mms_plugin/MmsPluginMessage.cpp b/plugin/mms_plugin/MmsPluginMessage.cpp index 3f4b4a3..44b633b 100755 --- a/plugin/mms_plugin/MmsPluginMessage.cpp +++ b/plugin/mms_plugin/MmsPluginMessage.cpp @@ -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 { diff --git a/plugin/sms_plugin/SmsPluginSetting.cpp b/plugin/sms_plugin/SmsPluginSetting.cpp index 84eaa7f..9ec7222 100755 --- a/plugin/sms_plugin/SmsPluginSetting.cpp +++ b/plugin/sms_plugin/SmsPluginSetting.cpp @@ -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!"); } diff --git a/plugin/sms_plugin/SmsPluginStorage.cpp b/plugin/sms_plugin/SmsPluginStorage.cpp index 5fd8645..492453a 100755 --- a/plugin/sms_plugin/SmsPluginStorage.cpp +++ b/plugin/sms_plugin/SmsPluginStorage.cpp @@ -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); diff --git a/utils/MsgUtilFunction.cpp b/utils/MsgUtilFunction.cpp index 392e088..0883576 100755 --- a/utils/MsgUtilFunction.cpp +++ b/utils/MsgUtilFunction.cpp @@ -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"); } -- 2.7.4