fix svace issues 83/100483/3
authorKyeonghun Lee <kh9090.lee@samsung.com>
Mon, 28 Nov 2016 08:56:46 +0000 (17:56 +0900)
committerKyeonghun Lee <kh9090.lee@samsung.com>
Tue, 29 Nov 2016 04:23:11 +0000 (13:23 +0900)
Change-Id: I297d3f7766fde9edce9f58b83286066a35db55fe
Signed-off-by: Kyeonghun Lee <kh9090.lee@samsung.com>
14 files changed:
CMakeLists.txt
framework/transaction-manager/MsgCmdHandlerTransport.cpp
include/framework/MsgPluginManager.h
packaging/msg-service.spec
plugin/mms_plugin/MmsPluginInternal.cpp
plugin/sms_plugin/SmsPluginCbMsgHandler.cpp
plugin/sms_plugin/SmsPluginTransport.cpp
plugin/sms_plugin/include/SmsPluginSetting.h
plugin/sms_plugin/include/SmsPluginTypes.h
utils/MsgUtilFunction.cpp
utils/MsgUtilMime.cpp
utils/MsgVMessage.cpp
vobject-engine/VCard.c
vobject-engine/VMessage.c

index f5bea00..cf49b10 100755 (executable)
@@ -32,7 +32,7 @@ ADD_DEFINITIONS(-DTZ_SYS_RO_APP_PATH="${TZ_SYS_RO_APP}")
 ADD_DEFINITIONS(-DTZ_SYS_GLOBALUSER_DATA_PATH="${TZ_SYS_GLOBALUSER_DATA}")
 ADD_DEFINITIONS(-DTZ_SYS_GLOBALUSER_DB_PATH="${TZ_SYS_GLOBALUSER_DB}")
 ADD_DEFINITIONS(-DTZ_SYS_HOME_PATH="${TZ_SYS_HOME}")
-ADD_DEFINITIONS(-DLIBDIR="${LIBDIR}")
+ADD_DEFINITIONS(-DLIB_INSTALL_DIR="${LIB_INSTALL_DIR}")
 
 CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
 CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
index 5448e2a..85eb318 100755 (executable)
@@ -1110,11 +1110,8 @@ int MsgResendMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
                err = MsgSubmitReq(&reqInfo, false);
 
                if (err == MSG_SUCCESS) {
+                       MSG_DEBUG("MsgSubmitReq() Success");
                        MsgTransactionManager::instance()->broadcastStorageChangeCB(MSG_SUCCESS, MSG_STORAGE_CHANGE_UPDATE, &msgIdList);
-                       if (err == MSG_SUCCESS)
-                               MSG_DEBUG("MsgSubmitReq() Success");
-                       else
-                               MSG_DEBUG("MsgSubmitReq() Fail, [%d]", err);
                } else {
                        MSG_DEBUG("MsgSubmitReq() Fail, [%d]", err);
                }
index 585ba09..1f1032b 100755 (executable)
@@ -94,8 +94,8 @@ typedef struct {
 } MSG_PLG_TABLE_T;
 
 static const MSG_PLG_TABLE_T __msg_plg_items[] = {
-       { MSG_SMS_TYPE, LIBDIR"/libmsg_sms_plugin.so" },
-       { MSG_MMS_TYPE, LIBDIR"/libmsg_mms_plugin.so" }
+       { MSG_SMS_TYPE, LIB_INSTALL_DIR"/libmsg_sms_plugin.so" },
+       { MSG_MMS_TYPE, LIB_INSTALL_DIR"/libmsg_mms_plugin.so" }
 };
 
 
index 06d18f3..531f279 100755 (executable)
@@ -134,7 +134,6 @@ Description: Message manager application
 %define APP_LOCALEDIR  %{APP_RESDIR}/locale
 %define APP_MANIFESTDIR        %{TZ_SYS_RO_PACKAGES}
 %endif
-%define LIBDIR %{_libdir}
 
 %prep
 %setup -q
index d6e00d8..60e8a16 100755 (executable)
@@ -652,6 +652,8 @@ void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTra
                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;
                }
        }
 
@@ -669,6 +671,8 @@ void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTra
                                        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;
                                        }
                                } else {
                                        addr_idx--;
@@ -690,6 +694,8 @@ void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTra
                                        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;
                                        }
                                } else {
                                        addr_idx--;
index 7847359..48d95ff 100755 (executable)
@@ -205,9 +205,7 @@ void SmsPluginCbMsgHandler::handleEtwsMsg(TapiHandle *handle, TelSmsEtwsMsg_t *p
 
 void SmsPluginCbMsgHandler::Decode2gCbMsg(TelSmsCbMsg_t *pCbMsg, SMS_CBMSG_PAGE_S *pCbPage)
 {
-       unsigned char cbData[pCbMsg->Length+1];
-
-       memset(cbData, 0x00, sizeof(cbData));
+       unsigned char cbData[pCbMsg->Length+1] = {0};
        memcpy(cbData, pCbMsg->szMsgData, pCbMsg->Length);
        cbData[pCbMsg->Length] = '\0';
 
@@ -269,7 +267,7 @@ void SmsPluginCbMsgHandler::Decode2gCbMsg(TelSmsCbMsg_t *pCbMsg, SMS_CBMSG_PAGE_
                dataLen = (dataLen*8) / 7;
 
                SmsPluginUDCodec udCodec;
-               char pageData[MAX_CBMSG_PAGE_SIZE+1];
+               char pageData[MAX_CBMSG_PAGE_SIZE*8/7] = {0};
                int unpackLen = udCodec.unpack7bitChar(&cbData[6], dataLen, 0, pageData);
 
                if (pCbPage->pageHeader.dcs.iso639Lang[0]) {
@@ -360,9 +358,7 @@ void SmsPluginCbMsgHandler::DecodeEtwsMsg(TelSmsEtwsMsg_t *pEtwsMsg, SMS_ETWS_PR
 
 void SmsPluginCbMsgHandler::Decode3gCbMsg(TelSmsCbMsg_t *pCbMsg, SMS_CBMSG_PAGE_S *pCbPage)
 {
-       unsigned char cbData[(MAX_CBMSG_PAGE_SIZE*MAX_CBMSG_PAGE_NUM)+1];
-
-       memset(cbData, 0x00, sizeof(cbData));
+       unsigned char cbData[MAX_CBMSG_TOTAL_PAGE_SIZE + 1] = {0};
        memcpy(cbData, pCbMsg->szMsgData, pCbMsg->Length);
        cbData[pCbMsg->Length] = '\0';
 
@@ -411,15 +407,15 @@ void SmsPluginCbMsgHandler::Decode3gCbMsg(TelSmsCbMsg_t *pCbMsg, SMS_CBMSG_PAGE_
        switch (pCbPage->pageHeader.dcs.codingScheme) {
        case SMS_CHARSET_7BIT: {
                for (int i = 0; i < pCbPage->pageHeader.totalPages; ++i) {
-                       char cbMessage[MAX_CBMSG_PAGE_SIZE] = {0, };
-                       dataLen = cbData[7+(i+1)*82 + i];
-                       memcpy(cbMessage, &cbData[7+(i*82)+ i], dataLen);
-
-                       dataLen = (dataLen*8) / 7;
+                       unsigned char cbMessage[MAX_CBMSG_PAGE_SIZE] = {0};
+                       dataLen = cbData[7 + (i + 1) * MAX_CBMSG_PAGE_SIZE + i];
 
                        if (dataLen > MAX_CBMSG_PAGE_SIZE)
                                THROW(MsgException::SMS_PLG_ERROR, "CB Msg Size is over MAX [%d]", dataLen);
 
+                       memcpy(cbMessage, &cbData[7+(i*MAX_CBMSG_PAGE_SIZE)+ i], dataLen);
+                       dataLen = (dataLen*8) / 7;
+
                        SmsPluginUDCodec udCodec;
                        int unpackLen = udCodec.unpack7bitChar((const unsigned char *)cbMessage, dataLen, 0, pCbPage->pageData + offset);
                        offset += unpackLen;
@@ -434,8 +430,8 @@ void SmsPluginCbMsgHandler::Decode3gCbMsg(TelSmsCbMsg_t *pCbMsg, SMS_CBMSG_PAGE_
                char cbMessage[MAX_CBMSG_PAGE_SIZE]= {0, };
 
                for (int i = 0; i < pCbPage->pageHeader.totalPages; ++i) {
-                       dataLen = cbData[7+(i+1)*82 + i];
-                       memcpy(cbMessage + offset, &cbData[7+(i*82)+ i], dataLen);
+                       dataLen = cbData[7+(i+1)*MAX_CBMSG_PAGE_SIZE + i];
+                       memcpy(cbMessage + offset, &cbData[7+(i*MAX_CBMSG_PAGE_SIZE)+ i], dataLen);
                        offset += dataLen;
                }
                dataLen = offset;
@@ -449,19 +445,19 @@ void SmsPluginCbMsgHandler::Decode3gCbMsg(TelSmsCbMsg_t *pCbMsg, SMS_CBMSG_PAGE_
                        pCbPage->pageLength = dataLen;
                }
 #else
-               char cbMessage[MAX_CBMSG_PAGE_SIZE] = {0, };
+               char cbMessage[MAX_CBMSG_PAGE_SIZE*MAX_CBMSG_PAGE_NUM+1] = {0, };
 
                for (int i = 0; i < pCbPage->pageHeader.totalPages; ++i) {
                        if (pCbPage->pageHeader.dcs.iso639Lang[0]) {
-                               dataLen = cbData[7+(i+1)*82 + i] - 2;
+                               dataLen = cbData[7+(i+1)*MAX_CBMSG_PAGE_SIZE + i] - 2;
                                if (dataLen > 0) {
-                                       memcpy(cbMessage + offset, &cbData[7+(i*82)+ i + 2], dataLen);
+                                       memcpy(cbMessage + offset, &cbData[7+(i*MAX_CBMSG_PAGE_SIZE)+ i + 2], dataLen);
                                        offset += dataLen;
                                }
                        } else {
-                               dataLen = cbData[7+(i+1)*82 + i];
+                               dataLen = cbData[7+(i+1)*MAX_CBMSG_PAGE_SIZE + i];
                                if (dataLen > 0) {
-                                       memcpy(cbMessage + offset, &cbData[7+(i*82)+ i], dataLen);
+                                       memcpy(cbMessage + offset, &cbData[7+(i*MAX_CBMSG_PAGE_SIZE)+ i], dataLen);
                                        offset += dataLen;
                                }
                        }
index 21af915..35bf189 100755 (executable)
@@ -313,7 +313,7 @@ void SmsPluginTransport::submitRequest(SMS_REQUEST_INFO_S *pReqInfo)
                                MSG_SMS_VLD_INFO("%d, SMS Send Start, %s->%s, %s",  pReqInfo->msgInfo.msgId, \
                                                                                                                                                        (msisdn == NULL)?"ME":msisdn, \
                                                                                                                                                        pReqInfo->msgInfo.addressList[0].addressVal, \
-                                                                                                                                                       (tapiRet == TAPI_API_SUCCESS)?"Success":"Fail");
+                                                                                                                                                       "Success");
 
                                MSG_SMS_VLD_TXT("%d, [%s]", pReqInfo->msgInfo.msgId, pReqInfo->msgInfo.msgText);
 
index 0b9093a..69f4a20 100755 (executable)
@@ -125,7 +125,7 @@ private:
        int     selectedSimIndex;
        char    meImei[MAX_ME_IMEI_LEN + 1];
 
-       bool    bMbdnEnable[MAX_TELEPHONY_HANDLE_CNT];
+       bool    bMbdnEnable[MAX_TELEPHONY_HANDLE_CNT+1];
 
        MsgMutex mx;
        MsgCndVar cv;
index e128e7a..c7c4c1a 100755 (executable)
@@ -48,7 +48,8 @@ extern "C"
 #define MAX_REL_TIME_PARAM_LEN         1
 #define MAX_UD_HEADER_NUM                      7
 #define MAX_SAT_TPDU_LEN                       175
-#define MAX_CBMSG_PAGE_SIZE            1252
+#define MAX_CBMSG_PAGE_SIZE            82
+#define MAX_CBMSG_TOTAL_PAGE_SIZE      1252 /* 6 + 1 + (MAX_CBMSG_PAGE_SIZE + 1) * MAX_CBMSG_PAGE_NUM = 1252 */
 #define MAX_ETWS_SIZE                  56
 #define MAX_CBMSG_PAGE_NUM             15
 #define MAX_SIM_SMS_NUM                        255
@@ -525,7 +526,7 @@ typedef struct _SMS_TIME_ABS_S {
        unsigned char hour;
        unsigned char minute;
        unsigned char second;
-       unsigned char timeZone;
+       int timeZone;
 } SMS_TIME_ABS_S;
 
 
@@ -731,7 +732,7 @@ typedef struct _SMS_CBMSG_PAGE_S {
        SMS_CBMSG_TYPE_T                        cbMsgType;                                                      /*CBS Msg or SCHEDULE Msg or CBS41 Msg */
        SMS_CBMSG_HEADER_S                      pageHeader;                                                     /**< CB Message Header */
        int                                                     pageLength;                                                     /**< message string length */
-       char                                                    pageData[MAX_CBMSG_PAGE_SIZE*8/7+1];            /**< user data */
+       char                                                    pageData[MAX_CBMSG_TOTAL_PAGE_SIZE*8/7+1];              /**< user data */
 } SMS_CBMSG_PAGE_S;
 
 
@@ -742,7 +743,7 @@ typedef struct _SMS_CBMSG_S {
        SMS_CODING_SCHEME_T             codingScheme;                                           /**< How to encode a message. */
        time_t                                          recvTime;                                                       /**< Msg Recv Time */
        int                                                     msgLength;                                                      /**< message string length */
-       char                                                    msgData[MAX_CBMSG_PAGE_SIZE*8/7*MAX_CBMSG_PAGE_NUM+1];          /**< user data */
+       char                                                    msgData[MAX_CBMSG_TOTAL_PAGE_SIZE*8/7+1];               /**< user data */
 } SMS_CBMSG_S;
 
 typedef struct _SMS_ETWS_PRIMARY_S {
index 3bf80da..61851c6 100755 (executable)
@@ -1287,6 +1287,11 @@ 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;
index 93cb916..3365748 100755 (executable)
 #include "MsgUtilMime.h"
 #include "MsgDebug.h"
 
+#define MIME_MAX_NUM   167
+#define EXT_MAX        68
+#define MIME_SUB_TYPE_VND      1
+#define MIME_SUB_TYPE_X                2
+
 typedef enum _MimeAppType {
        MIME_APPLICATION_NONE,
 
@@ -274,7 +279,8 @@ static const int mimeTableIndex[] = {
        121,            121,            121,
        122,            122,            122,
        129,            136,            144,
-       151,            161,            163
+       151,            161,            163,
+       MIME_MAX_NUM
 };
 
 static int mimeTableEnum[] =
@@ -474,11 +480,6 @@ static int mimeTableEnum[] =
 };
 
 
-#define MIME_MAX_NUM   167
-#define EXT_MAX        68
-#define MIME_SUB_TYPE_VND      1
-#define MIME_SUB_TYPE_X                2
-
 int __MimeGetTableIndexInt(MimeType mime);
 int __MimeGetTableIndexString(const char *szMime);
 MimeMainType __MimeGetMainTypeName(const char *szType);
index 3a8850c..109da57 100755 (executable)
@@ -1123,9 +1123,10 @@ char *MsgVMessageEncode(MSG_MESSAGE_INFO_S *pMsg)
                        }
                } else {
                        fileSize = strlen(pMsg->msgData);
-                       pFileData = (char *)calloc(1, fileSize+1);
+                       pFileData = new char[fileSize+1];
                        if (!pFileData)
                                goto __CATCH_FAIL__;
+                       memset(pFileData, 0x00, fileSize+1);
                        snprintf(pFileData, fileSize, "%s", pMsg->msgData);
                }
 
index d3aac24..72735e4 100755 (executable)
@@ -927,6 +927,9 @@ VTree* vcard_decode(char *pCardRaw)
                                memset(pTemp, 0, sizeof(VObject));
                                pTemp->property = type;
 
+                               if (pVCard == NULL)
+                                       goto CATCH;
+
                                if (pVCard->pTop == NULL) {
                                        pVCard->pTop = pTemp;
                                        pVCard->pCur = pTemp;
@@ -1041,7 +1044,7 @@ VTree* vcard_decode(char *pCardRaw)
 
        VFREE(pCardRawTmp);
 
-       if (pVCard->pTop == NULL)
+       if (pVCard == NULL || pVCard->pTop == NULL)
                goto CATCH;
 
        if (!vcard_ended)
index 782733d..50da899 100755 (executable)
@@ -788,7 +788,6 @@ VTree* vmsg_decode(char *pMsgRaw)
        int param_status = false;
        int numberedParam = 0;
        int enc = 0;
-       int start_status = 0;
        char* temp = NULL;
        char* pVTree = NULL;
        bool vmsg_ended = false;
@@ -841,19 +840,16 @@ VTree* vmsg_decode(char *pMsgRaw)
                                if (!strncmp(szMsgBegin, "VCARD", strlen("VCARD"))) {
                                        VDATA_TRACE("pVTree: %s", pVTree);
                                        pVCard = vcard_decode(pVTree);
-                                       pCurrent->pNext = pVCard;
+                                       if (pCurrent) {
+                                               pCurrent->pNext = pVCard;
+                                       }
                                        pCurrent = pVCard;
 
                                        dLen = ((strstr(pMsgRaw, "END:VCARD") + 9) - pMsgRaw);
                                        pMsgRaw += dLen;
                                } else {
-
-                                       if (start_status == 1)
-                                               goto CATCH;
-
                                        if (!strncmp(szMsgBegin, "VMSG", strlen("VMSG"))) {
                                                if ((pVMsg = (VTree*)calloc(1, sizeof(VTree))) == NULL) {
-                                                       start_status = 1;
                                                        goto CATCH;
                                                }
                                                memset(pVMsg, 0x00, sizeof(VTree));
@@ -865,7 +861,6 @@ VTree* vmsg_decode(char *pMsgRaw)
                                                pCurrent = pVMsg;
                                        } else if (!strncmp(szMsgBegin, "VBODY", strlen("VBODY"))) {
                                                if ((pVBody = (VTree*)calloc(1, sizeof(VTree))) == NULL) {
-                                                       start_status = 1;
                                                        goto CATCH;
                                                }
 
@@ -1023,7 +1018,7 @@ VTree* vmsg_decode(char *pMsgRaw)
        VDATA_TRACE("pMsgRawTmp: %s", pMsgRawTmp);
        /* VFREE(pMsgRawTmp); */
 
-       if (pVMsg->pTop == NULL) {
+       if (pVMsg && pVMsg->pTop == NULL) {
                VDATA_TRACE("pVMsg->Top: NULL");
                goto CATCH;
        }
@@ -1063,6 +1058,10 @@ char* vmsg_encode(VTree *pVMsgRaw)
        int                     total = 0;
        int                     cnt = 0;
 
+       if (!pVMsgRaw || !pVMsgRaw->pTop) {
+               return NULL;
+       }
+
        for (; cnt < pVMsgRaw->pTop->valueCount; cnt++) {
 
                if (pVMsgRaw->pTop->pszValue[cnt] == NULL)  {
@@ -1163,8 +1162,6 @@ char* vmsg_encode(VTree *pVMsgRaw)
                                                break;
                                }
                        }
-
-
                }
 
                switch (pTmpTree->treeType) {