Fix svace defect 70/61270/1
authorSangkoo Kim <sangkoo.kim@samsung.com>
Mon, 7 Mar 2016 05:51:19 +0000 (14:51 +0900)
committerSangkoo Kim <sangkoo.kim@samsung.com>
Mon, 7 Mar 2016 05:51:19 +0000 (14:51 +0900)
Change-Id: Iae1cdc158e1a182aabc26e39007a1c18a02054e2

13 files changed:
externals/MsgNotificationWrapper.cpp
externals/MsgSoundPlayer.cpp
framework/storage-handler/MsgStorageMessage.cpp
framework/transaction-manager/MsgTransManager.cpp
mapi/msg_storage.cpp
plugin/sms_plugin/SmsPluginSimMsg.cpp
plugin/sms_plugin/SmsPluginStorage.cpp
utils/MsgVMessage.cpp
vobject-engine/VCard.c
vobject-engine/VMessage.c
vobject-engine/include/VCard.h
vobject-engine/include/VMessage.h
vobject-engine/include/VTypes.h

index 35188bc..fed5d71 100755 (executable)
@@ -1944,8 +1944,10 @@ void setActiveIcon(notification_h noti_h, MSG_NOTI_INFO_S *noti_info)
                case MSG_WAP_SI_SMS:
                case MSG_WAP_SL_SMS:
                        setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_ACTIVE_PUSH_ICON_PATH);
+                       break;
                case MSG_SYNCML_CP:
                        setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_OTA_ICON_PATH);
+                       break;
                default:
                        if (noti_info->imagePath[0] != '\0')
                                setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, noti_info->imagePath);
@@ -1953,6 +1955,7 @@ void setActiveIcon(notification_h noti_h, MSG_NOTI_INFO_S *noti_info)
                                setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NO_CONTACT_PROFILE_ICON_PATH);
 
                        setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, MSG_MESSAGE_APP_SUB_ICON);
+                       break;
                }
 
                break;
index 4e89169..292642f 100755 (executable)
@@ -577,6 +577,7 @@ void MsgSoundPlayer::MsgSoundPlayMelody(char *pMsgToneFilePath)
 
        if (g_stream_info == NULL) {
                MSG_DEBUG("g_stream_info is NULL");
+               pthread_mutex_unlock(&muMmPlay);
                return;
        }
 
index 9324ab6..385cbb9 100755 (executable)
@@ -1103,7 +1103,7 @@ msg_error_t MsgStoDeleteAllMessageInFolder(msg_folder_id_t folderId, bool bOnlyD
        /*** **/
 
        /*** Delete Sim Message In Folder **/
-       if (folderId >= MSG_INBOX_ID) {
+       if ((unsigned char)folderId >= (unsigned char)MSG_INBOX_ID) {
                memset(sqlQuery, 0x00, sizeof(sqlQuery));
 
                snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MSG_ID FROM %s WHERE FOLDER_ID = %d AND STORAGE_ID = %d",
@@ -1674,7 +1674,7 @@ msg_error_t MsgStoMoveMessageToFolder(msg_message_id_t msgId, msg_folder_id_t de
        err = MsgStoUpdateConversation(dbHandle, convId);
 
        /* update notification */
-       if (destFolderId != MSG_SPAMBOX_ID)
+       if ((unsigned char)destFolderId != (unsigned char)MSG_SPAMBOX_ID)
                MsgRefreshAllNotification(true, false, MSG_ACTIVE_NOTI_TYPE_NONE);
 
        return err;
index f646510..725d673 100755 (executable)
@@ -303,6 +303,7 @@ void MsgTransactionManager::workerEventQueue()
        MSG_CMD_S* pCmd = NULL;
        int (*pfHandler)(const MSG_CMD_S*, char**) = NULL;
        char* pEventData = NULL;
+       unique_ptr<char*, void(*)(char**)> eventBuf(&pEventData, unique_ptr_deleter);
 
        int fd = -1;
        int eventSize = 0;
@@ -344,7 +345,6 @@ void MsgTransactionManager::workerEventQueue()
                MSG_DEBUG("Replying to fd [%d], size [%d]", fd, eventSize);
                servSock.write(fd, pEventData, eventSize);
                g_free(pCmd); pCmd = NULL;
-               g_free(pEventData); pEventData = NULL;
        }
 }
 
index b875a8f..eed39bf 100755 (executable)
@@ -617,7 +617,7 @@ EXPORT_API int msg_generate_message(msg_handle_t handle, msg_message_type_t msg_
                return MSG_ERR_INVALID_PARAMETER;
        }
 
-       if (folder_id >= MSG_MAX_FOLDER_ID) {
+       if ((unsigned char)folder_id >= (unsigned char)MSG_MAX_FOLDER_ID) {
                MSG_DEBUG("folderId is invalid [%d]", folder_id);
                return MSG_ERR_INVALID_PARAMETER;
        }
index 864a836..b57fd8c 100755 (executable)
@@ -401,7 +401,7 @@ msg_error_t SmsPluginSimMsg::saveClass2Message(const MSG_MESSAGE_INFO_S *pMsgInf
                TelSmsData_t simSmsData = {0, };
 
                if (submitData.segCount == 1) {
-                       memcpy(&simSmsData.SmsData.Sca, &simMsgDataInfo.sca, sizeof(simSmsData.SmsData.Sca));
+                       memcpy(&simSmsData.SmsData.Sca, &simMsgDataInfo.sca, sizeof(simSmsData.SmsData.Sca)-1);
                        memcpy(&simSmsData.SmsData.szData, &simMsgDataInfo.szData, sizeof(simSmsData.SmsData.szData)-1);
                        simSmsData.SmsData.MsgLength = simMsgDataInfo.msgLength;
 
@@ -415,7 +415,7 @@ msg_error_t SmsPluginSimMsg::saveClass2Message(const MSG_MESSAGE_INFO_S *pMsgInf
 
                        /* Set TPDU data */
                        int copyLen = (bufLen > TAPI_NETTEXT_SMDATA_SIZE_MAX) ? TAPI_NETTEXT_SMDATA_SIZE_MAX : bufLen;
-                       memcpy((void*)simSmsData.SmsData.Sca, &simMsgDataInfo.sca, sizeof(simSmsData.SmsData.Sca));
+                       memcpy((void*)simSmsData.SmsData.Sca, &simMsgDataInfo.sca, sizeof(simSmsData.SmsData.Sca)-1);
                        memcpy((void*)simSmsData.SmsData.szData, buf, (size_t)copyLen);
                        simSmsData.SmsData.szData[copyLen] = 0;
                        simSmsData.SmsData.MsgLength = copyLen;
index 0093140..dbeba09 100755 (executable)
@@ -638,7 +638,7 @@ msg_error_t SmsPluginStorage::deleteSmsMessage(msg_message_id_t msgId)
 
        dbHandle->endTrans(true);
 
-       if (folderId == MSG_INBOX_ID) {
+       if ((unsigned char)folderId == (unsigned char)MSG_INBOX_ID) {
                msgType.classType = MSG_CLASS_NONE;
 
                /**  Set memory status in SIM */
index b5d210d..47cab77 100755 (executable)
@@ -554,9 +554,9 @@ char* __msgsvc_vmsg_convert_tm_to_vdata_str(struct tm * tm)
        mon = tm->tm_mon + 1;
 
        if (tm->tm_hour >= 12)
-               strcpy(APM, "PM");
+               strncpy(APM, "PM", 2);
        else
-               strcpy(APM, "AM");
+               strncpy(APM, "AM", 2);
 
        if (tm->tm_hour > 12)
                hour = tm->tm_hour - 12;
@@ -565,40 +565,40 @@ char* __msgsvc_vmsg_convert_tm_to_vdata_str(struct tm * tm)
 
        switch(mon) {
                case 1:
-                       strcpy(month, "Jan");
+                       strncpy(month, "Jan", 3);
                        break;
                case 2:
-                       strcpy(month, "Feb");
+                       strncpy(month, "Feb", 3);
                        break;
                case 3:
-                       strcpy(month, "Mar");
+                       strncpy(month, "Mar", 3);
                        break;
                case 4:
-                       strcpy(month, "Apr");
+                       strncpy(month, "Apr", 3);
                        break;
                case 5:
-                       strcpy(month, "May");
+                       strncpy(month, "May", 3);
                        break;
                case 6:
-                       strcpy(month, "Jun");
+                       strncpy(month, "Jun", 3);
                        break;
                case 7:
-                       strcpy(month, "Jul");
+                       strncpy(month, "Jul", 3);
                        break;
                case 8:
-                       strcpy(month, "Aug");
+                       strncpy(month, "Aug", 3);
                        break;
                case 9:
-                       strcpy(month, "Sep");
+                       strncpy(month, "Sep", 3);
                        break;
                case 10:
-                       strcpy(month, "Oct");
+                       strncpy(month, "Oct", 3);
                        break;
                case 11:
-                       strcpy(month, "Nov");
+                       strncpy(month, "Nov", 3);
                        break;
                case 12:
-                       strcpy(month, "Dec");
+                       strncpy(month, "Dec", 3);
                        break;
                default:
                        MSG_DEBUG("invalid month number");
@@ -764,7 +764,7 @@ static inline int __msgsvc_vmsg_append_origin_address_vcard(MSG_MESSAGE_INFO_S *
        char originAddress[MAX_ADDRESS_VAL_LEN + 1] = {0, };
        bool isDisplayName = false;
 
-       if (pMsg->folderId == MSG_INBOX_ID) {
+       if ((unsigned char)(pMsg->folderId) == (unsigned char)MSG_INBOX_ID) {
                strcpy(originAddress, pMsg->addressList[0].addressVal);
        }
 
@@ -1955,7 +1955,7 @@ static inline msg_error_t __msgsvc_vmsg_get_msg(int ver, char *vmsg, MSG_MESSAGE
                                }
                                tempMsgText[i] = '\0';
                                char * temp = __msgsvc_vmsg_remove_escape_char(tempMsgText);
-                               strcpy(pMsg->msgText, temp);
+                               snprintf(pMsg->msgText, sizeof(pMsg->msgText), "%s", temp);
                                MSG_DEBUG("pMsg->msgText : %s", pMsg->msgText);
                                pMsg->dataSize = strlen(pMsg->msgText);
                                pMsg->bTextSms = true;
@@ -2031,6 +2031,7 @@ static inline msg_error_t __msgsvc_vmsg_get_msg(int ver, char *vmsg, MSG_MESSAGE
                        break;
                case VMSG_MSG_BEGIN:
                        end = __msgsvc_vmsg_get_msg_begin(pMsg, val, &vCardCnt);
+                       break;
                case VMSG_MSG_END:
                        end = __msgsvc_vmsg_get_msg_end(pMsg, val);
                        if (end) {
index 3e1b026..b622b37 100755 (executable)
@@ -814,8 +814,7 @@ VCardGetCharsetValue(int index)
  * @param       pVCardRaw            The raw data
  * @return      vObject             The result value
  */
-SLPAPI VTree*
-vcard_decode(char *pCardRaw)
+VTree* vcard_decode(char *pCardRaw)
 {
        VDATA_TRACE_BEGINE;
        char* szValue = NULL;
@@ -1057,7 +1056,7 @@ CATCH:
        VFREE(pTemp);
 CATCH1:
        VFREE(pCardRawTmp);
-       __VCardFreeVTreeMemory(pVCard);
+       vcard_free_vtree_memory(pVCard);
        VDATA_TRACE_END
        return NULL;
 }
@@ -1068,8 +1067,7 @@ CATCH1:
  * @param       pVCardRaw            Data which will be encoded
  * @return      char *              Encoded result
  */
-SLPAPI char*
-vcard_encode(VTree *pVCardRaw)
+char* vcard_encode(VTree *pVCardRaw)
 {
        VDATA_TRACE_BEGINE
        char*           pVCardRes = NULL;
@@ -1473,8 +1471,7 @@ __VCardParamEncode(VObject* pTypeObj, int* pEnc)
        return szParam;
 }
 
-SLPAPI bool
-vcard_free_vtree_memory(VTree * pTree)
+bool vcard_free_vtree_memory(VTree * pTree)
 {
        VDATA_TRACE_BEGINE
        if (pTree == NULL) {
index a23f61f..60ea296 100755 (executable)
@@ -765,8 +765,7 @@ VMsgGetCharsetValue(int index)
  * @param       pVMsgRaw            The raw data
  * @return      vObject             The result value
  */
-SLPAPI VTree*
-vmsg_decode(char *pMsgRaw)
+VTree* vmsg_decode(char *pMsgRaw)
 {
        VDATA_TRACE_BEGINE;
 
@@ -1045,7 +1044,7 @@ CATCH:
 CATCH1:
        VFREE(szMsgBegin);
        VFREE(pMsgRawTmp);
-       __VMsgFreeVTreeMemory(pVMsg);
+       vmsg_free_vtree_memory(pVMsg);
        VDATA_TRACE_END
        return NULL;
 }
@@ -1056,8 +1055,7 @@ CATCH1:
  * @param       pVMsgRaw            Data which will be encoded
  * @return      char *              Encoded result
  */
-SLPAPI char*
-vmsg_encode(VTree *pVMsgRaw)
+char* vmsg_encode(VTree *pVMsgRaw)
 {
        VDATA_TRACE_BEGINE
        char*           pVMsgRes = NULL;
@@ -1523,7 +1521,7 @@ __VMsgParamEncode(VObject* pTypeObj, int* pEnc)
        return szParam;
 }
 
-SLPAPI bool
+bool
 vmsg_free_vtree_memory(VTree * pTree)
 {
        VDATA_TRACE_BEGINE
index 4079e2c..88e9899 100755 (executable)
@@ -199,7 +199,7 @@ typedef enum
 * @param[in] pVCardRaw  Points to the vcard string.
 * @see vcard_encode
 */
-SLPAPI VTree*  vcard_decode(char* pVCardRaw);
+VTree* vcard_decode(char* pVCardRaw);
 
 /**
 * @fn char* vcard_encode(VTree* pVTree);
@@ -209,7 +209,7 @@ SLPAPI VTree*       vcard_decode(char* pVCardRaw);
 * @param[in] pVTree  Points to a VTree.
 * @see vcard_decode
 */
-SLPAPI char*   vcard_encode(VTree* pVTree);
+char*  vcard_encode(VTree* pVTree);
 
 /**
 * @fn char* vcard_free_vtree_memory(VTree* pTree);
@@ -218,7 +218,7 @@ SLPAPI char*        vcard_encode(VTree* pVTree);
 * @return      This function returns value of success or fail
 * @param[in] pVTree  Points to a VTree.
 */
-SLPAPI bool vcard_free_vtree_memory(VTree * pTree);
+bool vcard_free_vtree_memory(VTree * pTree);
 
 #ifdef __cplusplus
 }
index ddf2f6a..8a14bd4 100755 (executable)
@@ -177,7 +177,7 @@ typedef enum
 * @param[in] pVCardRaw  Points to the vcard string.
 * @see vcard_encode
 */
-SLPAPI VTree*  vmsg_decode(char* pVMsgRaw);
+VTree* vmsg_decode(char* pVMsgRaw);
 
 /**
 * @fn char* vcard_encode(VTree* pVTree);
@@ -187,7 +187,7 @@ SLPAPI VTree*       vmsg_decode(char* pVMsgRaw);
 * @param[in] pVTree  Points to a VTree.
 * @see vcard_decode
 */
-SLPAPI char*   vmsg_encode(VTree* pVTree);
+char*  vmsg_encode(VTree* pVTree);
 
 /**
 * @fn char* vcard_free_vtree_memory(VTree* pTree);
@@ -196,7 +196,7 @@ SLPAPI char*        vmsg_encode(VTree* pVTree);
 * @return      This function returns value of success or fail
 * @param[in] pVTree  Points to a VTree.
 */
-SLPAPI bool vmsg_free_vtree_memory(VTree * pTree);
+bool vmsg_free_vtree_memory(VTree * pTree);
 
 #ifdef __cplusplus
 }
index 15f7873..aab1f18 100755 (executable)
 #include "string.h"
 #include "ctype.h"
 
-#ifndef SLPAPI
-#define SLPAPI __attribute__ ((visibility("default")))
-#endif
-
 #define CR                             0x0d
 #define LF                             0x0a
 #define TAB                            0x09