From 1fbd6cdf9d68635b5d9786fab5433f41d75553b1 Mon Sep 17 00:00:00 2001 From: Seunghwan Lee Date: Wed, 6 Mar 2013 20:13:51 +0900 Subject: [PATCH] Fixed N_SE-25225 add mmsDataSize for Serialized MMS data in MSG_MESSAGE_HIDDEN_S Change-Id: I79092f37f91e086593b8e3e530e3e3283a73bca4 --- include/common/MsgInternalTypes.h | 1 + mapi/msg_message.cpp | 32 +++++++++++++++++--------------- mapi/msg_transport.cpp | 5 +++-- proxy/MsgHandleControl.cpp | 17 ++++++++++++----- utils/MsgMmsMessage.cpp | 2 +- 5 files changed, 34 insertions(+), 23 deletions(-) diff --git a/include/common/MsgInternalTypes.h b/include/common/MsgInternalTypes.h index feffe1d..70bc190 100755 --- a/include/common/MsgInternalTypes.h +++ b/include/common/MsgInternalTypes.h @@ -262,6 +262,7 @@ typedef struct size_t dataSize; /**< Indicates the data size. The unit is byte. */ void *pData; /**< Indicates the message payload information as a body. default character encoding is UTF-8*/ void *pMmsData; /**< Indicates the message payload information as a body. default character encoding is UTF-8*/ + size_t mmsDataSize; } MSG_MESSAGE_HIDDEN_S; /** diff --git a/mapi/msg_message.cpp b/mapi/msg_message.cpp index b78d7a3..b01381e 100755 --- a/mapi/msg_message.cpp +++ b/mapi/msg_message.cpp @@ -50,7 +50,7 @@ void msg_message_create_struct(msg_struct_s *msg_struct) msg->dataSize = 0; msg->pData = NULL; msg->pMmsData = NULL; - + msg->mmsDataSize = 0; /* Allocate memory for address list of message */ msg_struct_list_s *addr_list = (msg_struct_list_s *)new msg_struct_list_s; @@ -86,6 +86,7 @@ int msg_message_release(msg_struct_s **msg_struct) if (msg->pMmsData) { delete [] static_cast(msg->pMmsData); msg->pMmsData = NULL; + msg->mmsDataSize = 0; } // Memory Free @@ -514,22 +515,23 @@ void msg_message_copy_message(MSG_MESSAGE_HIDDEN_S *pSrc, MSG_MESSAGE_HIDDEN_S * pDst->direction = pSrc->direction; pDst->bPortValid = pSrc->bPortValid; pDst->dataSize = pSrc->dataSize; + pDst->mmsDataSize = pSrc->mmsDataSize; memcpy(pDst->subject, pSrc->subject, sizeof(pDst->subject)); - if(pSrc->dataSize) + + if(pSrc->pMmsData && pSrc->mmsDataSize) { - if(pSrc->pMmsData) - { - pDst->pMmsData = new char[pSrc->dataSize + 1]; - memcpy(pDst->pMmsData, pSrc->pMmsData, pSrc->dataSize); - } - if(pSrc->pData) - { - int data_len = strlen((const char *)pSrc->pData); - pDst->pData = new char[data_len + 1]; - memset(pDst->pData, 0x00, data_len + 1); - strncpy((char *)pDst->pData, (const char *)pSrc->pData, data_len); - } + pDst->pMmsData = new char[pSrc->mmsDataSize]; + memcpy(pDst->pMmsData, pSrc->pMmsData, pSrc->mmsDataSize); } + + if(pSrc->dataSize && pSrc->pData) + { + int data_len = strlen((const char *)pSrc->pData); + pDst->pData = new char[data_len + 1]; + memset(pDst->pData, 0x00, data_len + 1); + strncpy((char *)pDst->pData, (const char *)pSrc->pData, data_len); + } + msg_struct_list_s *src_addrlist = pSrc->addr_list; msg_struct_list_s *dst_addrlist = pDst->addr_list; dst_addrlist->nCount = src_addrlist->nCount; @@ -704,7 +706,7 @@ EXPORT_API int msg_set_mms_struct(msg_struct_t msg_struct_handle, msg_struct_t m convert_to_mmsdata(mms_struct, tmp_mms_data); - msg_data->pMmsData = _MsgMmsSerializeMessageData(tmp_mms_data, &(msg_data->dataSize)); + msg_data->pMmsData = _MsgMmsSerializeMessageData(tmp_mms_data, &(msg_data->mmsDataSize)); _MsgMmsReleasePageList(tmp_mms_data); _MsgMmsReleaseRegionList(tmp_mms_data); diff --git a/mapi/msg_transport.cpp b/mapi/msg_transport.cpp index e680a61..1b15529 100755 --- a/mapi/msg_transport.cpp +++ b/mapi/msg_transport.cpp @@ -512,9 +512,9 @@ EXPORT_API int msg_mms_send_message(msg_handle_t handle, msg_struct_t req) MSG_MESSAGE_HIDDEN_S *reqmsg = (MSG_MESSAGE_HIDDEN_S*)msg_s->data; - if (reqmsg->dataSize <= 0) + if (reqmsg->mmsDataSize <= 0) { - MSG_FATAL("MMS data size is invalid"); + MSG_FATAL("MMS data size is invalid [%d]", reqmsg->mmsDataSize); return MSG_ERR_INVALID_PARAMETER; } @@ -571,6 +571,7 @@ EXPORT_API int msg_mms_send_read_report(msg_handle_t handle, msg_message_id_t ms reqmsg->subType = MSG_READREPLY_MMS; reqmsg->dataSize = read_report_datasize; + reqmsg->mmsDataSize = read_report_datasize; reqmsg->pMmsData = read_report_data; err = msg_submit_req(handle, req_t); diff --git a/proxy/MsgHandleControl.cpp b/proxy/MsgHandleControl.cpp index 58c32d5..34d4808 100755 --- a/proxy/MsgHandleControl.cpp +++ b/proxy/MsgHandleControl.cpp @@ -237,7 +237,12 @@ void MsgHandle::convertMsgStruct(const MSG_MESSAGE_HIDDEN_S *pSrc, MSG_MESSAGE_I if(pSrc->subType == MSG_READREPLY_MMS) { memset(pDest->msgData, 0x00, sizeof(pDest->msgData)); - memcpy(pDest->msgData, pSrc->pMmsData, pSrc->dataSize); + + if (pSrc->mmsDataSize < MAX_MSG_DATA_LEN) + memcpy(pDest->msgData, pSrc->pMmsData, pSrc->mmsDataSize); + else + memcpy(pDest->msgData, pSrc->pMmsData, MAX_MSG_DATA_LEN); + } else { // Save Message Data into File char fileName[MSG_FILENAME_LEN_MAX+1]; @@ -253,9 +258,8 @@ void MsgHandle::convertMsgStruct(const MSG_MESSAGE_HIDDEN_S *pSrc, MSG_MESSAGE_I strncpy(pFileNameExt,"JAVA", MSG_FILENAME_LEN_MAX); } - MSG_DEBUG("Save Message Data into file : size[%d] name[%s]", pDest->dataSize, fileName); - - if (MsgWriteIpcFile(fileName, (char*)pSrc->pMmsData, pSrc->dataSize) == false) + MSG_DEBUG("Save Message Data into file : size[%d] name[%s]", pSrc->mmsDataSize, fileName); + if (MsgWriteIpcFile(fileName, (char*)pSrc->pMmsData, pSrc->mmsDataSize) == false) THROW(MsgException::FILE_ERROR, "MsgWriteIpcFile error"); memset(pDest->msgData, 0x00, sizeof(pDest->msgData)); @@ -338,7 +342,7 @@ void MsgHandle::convertMsgStruct(const MSG_MESSAGE_INFO_S *pSrc, MSG_MESSAGE_HID // Get Message Data from File if (pSrc->networkStatus != MSG_NETWORK_RETRIEVE_FAIL) { - MSG_DEBUG("Get Message Data from file : size[%d] name[%s]\n", pDest->dataSize, pSrc->msgData); + if (MsgOpenAndReadFile(pSrc->msgData, &pFileData, &fileSize) == false) THROW(MsgException::FILE_ERROR, "MsgOpenAndReadFile error"); @@ -358,9 +362,11 @@ void MsgHandle::convertMsgStruct(const MSG_MESSAGE_INFO_S *pSrc, MSG_MESSAGE_HID memset(pDest->pData, 0x00, strlen(pSrc->msgText)+1); strncpy((char*)pDest->pData, pSrc->msgText, strlen(pSrc->msgText)); } + pDest->mmsDataSize = fileSize; pDest->pMmsData = (void*)new char[fileSize]; memset(pDest->pMmsData, 0x00, fileSize); memcpy(pDest->pMmsData, pFileData, fileSize); + MSG_DEBUG("Get Message Data from file : size[%d] name[%s]", pDest->mmsDataSize, pSrc->msgData); } } } else { @@ -383,6 +389,7 @@ void MsgHandle::convertMsgStruct(const MSG_MESSAGE_INFO_S *pSrc, MSG_MESSAGE_HID strncpy((char*)pDest->pData, pSrc->msgText, strlen(pSrc->msgText)); } + pDest->mmsDataSize = pDest->dataSize; pDest->pMmsData = (void*)new char[pDest->dataSize]; memset(pDest->pMmsData, 0x00, pDest->dataSize); memcpy(pDest->pMmsData, pSrc->msgData, pDest->dataSize); diff --git a/utils/MsgMmsMessage.cpp b/utils/MsgMmsMessage.cpp index f4ff2b7..ec0aeba 100755 --- a/utils/MsgMmsMessage.cpp +++ b/utils/MsgMmsMessage.cpp @@ -311,7 +311,7 @@ char* _MsgMmsSerializeMessageData(const MMS_MESSAGE_DATA_S* pMsgData, unsigned i + sizeof(MsgDrmType) + MSG_FILEPATH_LEN_MAX #endif + MAX_SMIL_TRANSIN_ID + MAX_SMIL_TRANSOUT_ID + - 7 * sizeof(int) + 3* sizeof(bool) + sizeof(MmsTextDirection) + sizeof(MmsSmilFontType)); + 7 * sizeof(int) + 4* sizeof(bool) + sizeof(MmsTextDirection) /*+ sizeof(MmsSmilFontType)*/); } else { bufsize += (sizeof(MmsSmilMediaType) + MSG_FILENAME_LEN_MAX + 2 * MSG_FILEPATH_LEN_MAX + MSG_MSG_ID_LEN + 1 + MAX_SMIL_ALT_LEN + MAX_SMIL_REGION_ID -- 2.7.4