From 8e11a02348eb5effb6b84ac587dcb8b3ca905828 Mon Sep 17 00:00:00 2001 From: Changseok Oh Date: Wed, 9 Jan 2013 22:03:18 +0900 Subject: fix prevent issue --- plugin/mms_plugin/CMakeLists.txt | 2 +- plugin/mms_plugin/MmsPluginCodecCommon.cpp | 192 ++++++++++++- plugin/mms_plugin/MmsPluginDecode.cpp | 348 +++-------------------- plugin/mms_plugin/MmsPluginInternal.cpp | 10 +- plugin/mms_plugin/MmsPluginSmil.cpp | 39 +-- plugin/mms_plugin/MmsPluginStorage.cpp | 100 +++---- plugin/mms_plugin/MmsPluginUserAgent.cpp | 4 +- plugin/mms_plugin/MmsPluginUtil.cpp | 39 ++- plugin/mms_plugin/include/MmsPluginCodecCommon.h | 4 + plugin/mms_plugin/include/MmsPluginDecode.h | 3 - plugin/mms_plugin/include/MmsPluginUtil.h | 4 +- 11 files changed, 334 insertions(+), 411 deletions(-) (limited to 'plugin/mms_plugin') diff --git a/plugin/mms_plugin/CMakeLists.txt b/plugin/mms_plugin/CMakeLists.txt index 047d7b5..a9a0742 100755 --- a/plugin/mms_plugin/CMakeLists.txt +++ b/plugin/mms_plugin/CMakeLists.txt @@ -38,7 +38,7 @@ SET(MMS-PLUGIN-SRCS INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/include/common ${CMAKE_SOURCE_DIR}/include/framework - ${CMAKE_SOURCE_DIR}/include/msg_helper + #${CMAKE_SOURCE_DIR}/include/msg_helper ${CMAKE_SOURCE_DIR}/include/utils ${CMAKE_SOURCE_DIR}/include/mapi ${CMAKE_CURRENT_SOURCE_DIR}/include diff --git a/plugin/mms_plugin/MmsPluginCodecCommon.cpp b/plugin/mms_plugin/MmsPluginCodecCommon.cpp index 86878c4..d3b565b 100755 --- a/plugin/mms_plugin/MmsPluginCodecCommon.cpp +++ b/plugin/mms_plugin/MmsPluginCodecCommon.cpp @@ -903,7 +903,6 @@ char *MsgDecodeText(char *pOri) int nCharset = MSG_CHARSET_UTF8; int nTemp = 0; char *pReturnStr = NULL; - char *pConvertedStr = NULL; char szTempBuf[MSG_LOCAL_TEMP_BUF_SIZE] = {0}; @@ -946,6 +945,8 @@ char *MsgDecodeText(char *pOri) *pDecQ = '\0'; nCharset = _MsgGetCode(MSG_CHARSET, pDecStart + 2); + if(nCharset < 0) + goto __CATCH; *pDecQ = MSG_CH_QUESTION; } @@ -1090,11 +1091,6 @@ __RETURN: pTemp = NULL; } - if (pConvertedStr) { - free(pConvertedStr); - pConvertedStr = NULL; - } - if(pRe) { free(pRe); pRe = NULL; @@ -1109,11 +1105,6 @@ __RETURN: __CATCH: - if (pConvertedStr) { - free(pConvertedStr); - pConvertedStr = NULL; - } - if(pRe) { free(pRe); pRe = NULL; @@ -1801,4 +1792,183 @@ bool MmsInitMsgDRMInfo(MsgDRMInfo *pMsgDrmInfo) return true; } + +void MmsReleaseMsgDRMInfo(MsgDRMInfo *pDrmInfo) +{ + MSG_DEBUG("_MsgFreeDRMInfo: S T A R T !!! \n"); + + if (pDrmInfo == NULL) { + MSG_DEBUG("pDrmInfo is NULL"); + return; + } + + if (pDrmInfo->szContentDescription) { + free(pDrmInfo->szContentDescription); + pDrmInfo->szContentDescription = NULL; + } + + if (pDrmInfo->szContentVendor) { + free(pDrmInfo->szContentVendor); + pDrmInfo->szContentVendor = NULL; + } + + if (pDrmInfo->szContentName) { + free(pDrmInfo->szContentName); + pDrmInfo->szContentName = NULL; + } + + if (pDrmInfo->szContentURI) { + free(pDrmInfo->szContentURI); + pDrmInfo->szContentURI = NULL; + } + + if (pDrmInfo->szRightIssuer) { + free(pDrmInfo->szRightIssuer); + pDrmInfo->szRightIssuer = NULL; + } + + if (pDrmInfo->szDrm2FullPath) { + free(pDrmInfo->szDrm2FullPath); + pDrmInfo->szDrm2FullPath = NULL; + } + + pDrmInfo->contentType = MIME_UNKNOWN; + pDrmInfo->drmType = MSG_DRM_TYPE_NONE; +} + #endif + +bool MmsReleaseMmsAttrib(MmsAttrib *pAttrib) +{ + MSG_BEGIN(); + + if (pAttrib == NULL) { + MSG_DEBUG("pAttrib is NULL"); + return false; + } + + if (pAttrib->szTo) { + free(pAttrib->szTo); + pAttrib->szTo = NULL; + } + + if (pAttrib->szCc) { + free(pAttrib->szCc); + pAttrib->szCc = NULL; + } + + if (pAttrib->szBcc) { + free(pAttrib->szBcc); + pAttrib->szBcc = NULL; + } + + //check if pMultiStatus should be freed or not, because pMultiStatus is not allocated + if (pAttrib->pMultiStatus) { + MmsMsgMultiStatus *pMultiStatus = pAttrib->pMultiStatus; + MmsMsgMultiStatus *pCurStatus = NULL; + + while (pMultiStatus != NULL ) { + pCurStatus = pMultiStatus; + pMultiStatus = pMultiStatus->pNext; + + if (pCurStatus) { + free(pCurStatus); + pCurStatus = NULL; + } + } + + pAttrib->pMultiStatus = NULL; + } + + + MSG_END(); + + return true; +} + +bool MmsReleaseMsgBody(MsgBody *pBody, int type) +{ + MSG_BEGIN(); + + if (pBody == NULL) { + MSG_DEBUG("pBody == NULL \n" ); + MSG_END(); + + return false; + } + + switch (type) { + case MIME_MULTIPART_REPORT: + case MIME_APPLICATION_VND_OMA_DRM_MESSAGE: + case MIME_APPLICATION_VND_WAP_MULTIPART_MIXED: + case MIME_APPLICATION_VND_WAP_MULTIPART_RELATED: + case MIME_APPLICATION_VND_WAP_MULTIPART_ASTERIC: + case MIME_MULTIPART_MIXED: + case MIME_MULTIPART_RELATED: + case MIME_MULTIPART_ALTERNATIVE: + case MIME_APPLICATION_VND_WAP_MULTIPART_ALTERNATIVE: + { + MsgMultipart *pMulti = pBody->body.pMultipart; + MsgMultipart *pCurrPart = NULL; + MsgBody *pPresentation = pBody->pPresentationBody; + while (pMulti != NULL) { + pCurrPart = pMulti; + + pMulti = pMulti->pNext; + + if (pCurrPart) { +#ifdef __SUPPORT_DRM__ + MmsReleaseMsgDRMInfo(&pCurrPart->type.drmInfo); +#endif + + if (pCurrPart->pBody) { + if (pCurrPart->pBody->body.pBinary) { + free(pCurrPart->pBody->body.pBinary); + pCurrPart->pBody->body.pBinary = NULL; + } + free(pCurrPart->pBody); + pCurrPart->pBody = NULL; + } + free(pCurrPart); + pCurrPart = NULL; + } + } + + pBody->body.pMultipart = NULL; + + if (pPresentation) { + if (pPresentation->body.pText) { + free(pPresentation->body.pText); + pPresentation->body.pText = NULL; + } + free(pPresentation); + pBody->pPresentationBody = NULL; + } + + MmsInitMsgType(&pBody->presentationType); + + break; + } + + default: + /* Any single part */ + if (pBody->body.pBinary) { + free(pBody->body.pBinary); + pBody->body.pBinary = NULL; + } + + break; + } + + MSG_END(); + return true; +} + +void MmsReleaseMmsMsg(MmsMsg *pMmsMsg) +{ + if (pMmsMsg) { + MmsReleaseMsgBody(&pMmsMsg->msgBody, pMmsMsg->msgType.type); + MmsReleaseMmsAttrib(&pMmsMsg->mmsAttrib); + bzero(pMmsMsg, sizeof(MmsMsg)); + } +} diff --git a/plugin/mms_plugin/MmsPluginDecode.cpp b/plugin/mms_plugin/MmsPluginDecode.cpp index 3a1c39a..decd4d7 100755 --- a/plugin/mms_plugin/MmsPluginDecode.cpp +++ b/plugin/mms_plugin/MmsPluginDecode.cpp @@ -79,9 +79,6 @@ static int __MmsBinaryDecodeContentType(FILE *pFile, MsgType *pMsgType, int tota static bool __MmsBinaryDecodeDRMContent(FILE *pFile, char *szFilePath, MsgType *pMsgType, MsgBody *pMsgBody, unsigned int bodyLength, int totalLength); #endif -static bool __MsgInitMsgBody(MsgBody *pMsgBody); -static bool __MsgInitMsgType(MsgType *pMsgType); - //util funcion static void __MsgRemoveFilePath(char *pSrc); static bool __MsgChangeSpace(char *pOrg, char **ppNew); @@ -108,7 +105,6 @@ static bool __MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody); static bool __MsgIsHexChar(char *pSrc); static char __MsgConvertHexValue(char *pSrc); static int __MsgConvertCharToInt(char ch); -static bool __MsgInitMsgContentParam(MsgContentParam *pMsgContentParam); static bool __MsgCopyNestedMsgType(MsgType *pMsgType1, MsgType *pMsgType2); static bool __MsgCopyNestedMsgParam(MsgContentParam *pParam1, MsgContentParam *pParam2); static bool __MsgIsMultipartMixed(int type); @@ -2461,7 +2457,8 @@ __RETURN: __CATCH: if (isFileCreated) - remove(szTempFilePath); + if(remove(szTempFilePath) != 0) + MSG_DEBUG("remove fail"); if (pRawData) { free(pRawData); @@ -2818,13 +2815,10 @@ bool MmsDrm2ConvertMsgBody(char *szOriginFilePath) pszMmsLoadTempBuf = NULL; } - if (pszOrgData) { - free(pszOrgData); - pszOrgData = NULL; - } - - remove(szTempFile); - remove(szTempFilePath); + if(remove(szTempFile) != 0) + MSG_DEBUG("remove fail"); + if(remove(szTempFilePath) != 0) + MSG_DEBUG("remove fail"); return true; @@ -2886,9 +2880,9 @@ bool MmsDrm2ReadMsgConvertedBody(MSG_MESSAGE_INFO_S *pMsg, bool bSavePartsAsTemp MmsPluginStorage::instance()->getMmsMessage(&pMmsMsg); MmsUnregisterDecodeBuffer(); #ifdef __SUPPORT_DRM__ - MsgFreeDRMInfo(&pMmsMsg->msgType.drmInfo); + MmsReleaseMsgDRMInfo(&pMmsMsg->msgType.drmInfo); #endif - MsgFreeBody(&pMmsMsg->msgBody, pMmsMsg->msgType.type); + MmsReleaseMsgBody(&pMmsMsg->msgBody, pMmsMsg->msgType.type); if (MmsReadMsgBody(pMsg->msgId, bSavePartsAsTempFiles, bRetrieved, retrievedPath) == false) { MSG_DEBUG("MmsDrm2ReadMsgConvertedBody: _MmsReadMsgBody with converted file is failed\n"); @@ -3876,9 +3870,6 @@ static bool __MmsBinaryDecodeEncodedString(FILE *pFile, char *szBuff, int bufLen int charSetLen = 0; int nTemp = 0; char *pData = NULL; - char *pTempData = NULL; - unsigned short *mszTempStr = NULL; - char *pConvertedStr = NULL; MSG_DEBUG("__MmsBinaryDecodeEncodedString: decode string..\n"); @@ -3946,6 +3937,10 @@ static bool __MmsBinaryDecodeEncodedString(FILE *pFile, char *szBuff, int bufLen const char *pFromCharSet = MmsPluginTextConvertGetCharSet(charset_code); if (pFromCharSet == NULL || !strcmp(pFromCharSet, pToCharSet)) { + if (pData) { + free(pData); + pData = NULL; + } return true; } @@ -3968,22 +3963,6 @@ static bool __MmsBinaryDecodeEncodedString(FILE *pFile, char *szBuff, int bufLen pData = NULL; } - if (pTempData) { - free(pTempData); - pTempData = NULL; - } - - if (mszTempStr) { - free(mszTempStr); - mszTempStr = NULL; - } - - if (pConvertedStr) { - free(pConvertedStr); - pConvertedStr = NULL; - } - - return true; __CATCH: @@ -3993,21 +3972,6 @@ __CATCH: pData = NULL; } - if (pTempData) { - free(pTempData); - pTempData = NULL; - } - - if (mszTempStr) { - free(mszTempStr); - mszTempStr = NULL; - } - - if (pConvertedStr) { - free(pConvertedStr); - pConvertedStr = NULL; - } - return false; } @@ -4363,7 +4327,7 @@ bool MmsReadMsgBody(msg_message_id_t msgID, bool bSavePartsAsTempFiles, bool bRe if ((mmsHeader.msgType.type == MIME_APPLICATION_VND_WAP_MULTIPART_MIXED)||(mmsHeader.msgType.type == MIME_MULTIPART_MIXED)) { if ((pMsg->nPartCount >= attachmax)&&(pMultipart->pNext != NULL)) { - MsgFreeBody(pMultipart->pNext->pBody, pMultipart->pNext->type.type); + MmsReleaseMsgBody(pMultipart->pNext->pBody, pMultipart->pNext->type.type); free(pMultipart->pNext->pBody); pMultipart->pNext->pBody= NULL; @@ -4455,10 +4419,10 @@ __CATCH: } #ifdef __SUPPORT_DRM__ - MsgFreeDRMInfo(&pMsg->msgType.drmInfo); + MmsReleaseMsgDRMInfo(&pMsg->msgType.drmInfo); #endif - MsgFreeBody(&pMsg->msgBody, pMsg->msgType.type); + MmsReleaseMsgBody(&pMsg->msgBody, pMsg->msgType.type); MSG_DEBUG("_MmsReadMsgBody: E N D (fail) ******************** \n"); return false; @@ -5075,8 +5039,8 @@ static MsgMultipart *__MsgAllocMultipart(void) goto __CATCH; } - __MsgInitMsgType(&pMultipart->type); - __MsgInitMsgBody(pMultipart->pBody); + MmsInitMsgType(&pMultipart->type); + MmsInitMsgBody(pMultipart->pBody); pMultipart->pNext = NULL; @@ -5097,70 +5061,6 @@ __CATCH: return NULL; } -static bool __MsgInitMsgType(MsgType *pMsgType) -{ - pMsgType->offset = 0; - pMsgType->size = 0; - pMsgType->contentSize = 0; - pMsgType->disposition = 0; - pMsgType->encoding = 0; - pMsgType->type = MIME_UNKNOWN; -#ifdef FEATURE_JAVA_MMS_MIME - pMsgType->szMimeString[0] ='\0'; -#endif - pMsgType->section = 0; - - pMsgType->szOrgFilePath[0] = '\0'; - pMsgType->szContentID[0] = '\0'; - pMsgType->szContentLocation[0] = '\0'; - - pMsgType->szContentRepPos[0] = '\0'; - pMsgType->szContentRepSize[0] = '\0'; - pMsgType->szContentRepIndex[0] = '\0'; - - __MsgInitMsgContentParam(&pMsgType->param); -#ifdef __SUPPORT_DRM__ - MmsInitMsgDRMInfo(&pMsgType->drmInfo); -#endif - - return true; -} - -static bool __MsgInitMsgContentParam(MsgContentParam *pMsgContentParam) -{ - pMsgContentParam->charset = MSG_CHARSET_UNKNOWN; - pMsgContentParam->type = MIME_UNKNOWN; - pMsgContentParam->szBoundary[0] = '\0'; - pMsgContentParam->szFileName[0] = '\0'; - pMsgContentParam->szName[0] = '\0'; -#ifdef FEATURE_JAVA_MMS - pMsgContentParam->szApplicationID = NULL; - pMsgContentParam->szReplyToApplicationID = NULL; -#endif - pMsgContentParam->szStart[0] = '\0'; - pMsgContentParam->szStartInfo[0] = '\0'; - pMsgContentParam->pPresentation = NULL; - - pMsgContentParam->reportType = MSG_PARAM_REPORT_TYPE_UNKNOWN; // add only used as parameter of Content-Type: multipart/report; report-type - - return true; -} - -static bool __MsgInitMsgBody(MsgBody *pMsgBody) -{ - pMsgBody->offset = 0; - pMsgBody->size = 0; - pMsgBody->body.pText = NULL; - pMsgBody->szOrgFilePath[0] = '\0'; - - __MsgInitMsgType(&pMsgBody->presentationType); - pMsgBody->pPresentationBody = NULL; - - memset(pMsgBody->szOrgFilePath, 0, MSG_FILEPATH_LEN_MAX); - - return true; -} - static MsgPresentationFactor __MsgIsPresentationEx(MsgType *multipartType, char* szStart, MimeType typeParam) { char szTmpStart[MSG_MSG_ID_LEN + 3] = { 0, }; @@ -5254,7 +5154,7 @@ static void __MsgConfirmPresentationPart(MsgType *pMsgType, MsgBody *pMsgBody, M pMsgBody->size -= pPresentationInfo->pCurPresentation->pBody->size; if (pPresentationInfo->pCurPresentation) { #ifdef __SUPPORT_DRM__ - MsgFreeDRMInfo(&pPresentationInfo->pCurPresentation->type.drmInfo); + MmsReleaseMsgDRMInfo(&pPresentationInfo->pCurPresentation->type.drmInfo); #endif free(pPresentationInfo->pCurPresentation); pPresentationInfo->pCurPresentation = NULL; @@ -5287,7 +5187,7 @@ static void __MsgConfirmPresentationPart(MsgType *pMsgType, MsgBody *pMsgBody, M pNextPart = pNextPart->pNext; if (pRemovePart->pBody) { - MsgFreeBody(pRemovePart->pBody, pRemovePart->type.type); + MmsReleaseMsgBody(pRemovePart->pBody, pRemovePart->type.type); free(pRemovePart->pBody); pRemovePart->pBody = NULL; } @@ -5297,9 +5197,9 @@ static void __MsgConfirmPresentationPart(MsgType *pMsgType, MsgBody *pMsgBody, M } } else { #ifdef __SUPPORT_DRM__ - MsgFreeDRMInfo(&pMsgBody->presentationType.drmInfo); + MmsReleaseMsgDRMInfo(&pMsgBody->presentationType.drmInfo); #endif - __MsgInitMsgType(&pMsgBody->presentationType); + MmsInitMsgType(&pMsgBody->presentationType); pMsgBody->pPresentationBody = NULL; } } @@ -5325,48 +5225,6 @@ static bool __MsgIsPresentablePart(int type) } #ifdef __SUPPORT_DRM__ -void MsgFreeDRMInfo(MsgDRMInfo *pDrmInfo) -{ - MSG_DEBUG("_MsgFreeDRMInfo: S T A R T !!! \n"); - - if (pDrmInfo == NULL) { - MSG_DEBUG("pDrmInfo is NULL"); - return; - } - - if (pDrmInfo->szContentDescription) { - free(pDrmInfo->szContentDescription); - pDrmInfo->szContentDescription = NULL; - } - - if (pDrmInfo->szContentVendor) { - free(pDrmInfo->szContentVendor); - pDrmInfo->szContentVendor = NULL; - } - - if (pDrmInfo->szContentName) { - free(pDrmInfo->szContentName); - pDrmInfo->szContentName = NULL; - } - - if (pDrmInfo->szContentURI) { - free(pDrmInfo->szContentURI); - pDrmInfo->szContentURI = NULL; - } - - if (pDrmInfo->szRightIssuer) { - free(pDrmInfo->szRightIssuer); - pDrmInfo->szRightIssuer = NULL; - } - - if (pDrmInfo->szDrm2FullPath) { - free(pDrmInfo->szDrm2FullPath); - pDrmInfo->szDrm2FullPath = NULL; - } - - pDrmInfo->contentType = MIME_UNKNOWN; - pDrmInfo->drmType = MSG_DRM_TYPE_NONE; -} bool MsgCopyDrmInfo(MsgType *pPartType) { @@ -5428,134 +5286,7 @@ static bool __MsgIsText(int type) } } -bool MsgFreeAttrib(MmsAttrib *pAttrib) -{ - MSG_BEGIN(); - - if (pAttrib == NULL) { - MSG_DEBUG("pAttrib is NULL"); - return false; - } - - if (pAttrib->szTo) { - free(pAttrib->szTo); - pAttrib->szTo = NULL; - } - - if (pAttrib->szCc) { - free(pAttrib->szCc); - pAttrib->szCc = NULL; - } - - if (pAttrib->szBcc) { - free(pAttrib->szBcc); - pAttrib->szBcc = NULL; - } - - //check if pMultiStatus should be freed or not, because pMultiStatus is not allocated - if (pAttrib->pMultiStatus) { - MmsMsgMultiStatus *pMultiStatus = pAttrib->pMultiStatus; - MmsMsgMultiStatus *pCurStatus = NULL; - - while (pMultiStatus != NULL ) { - pCurStatus = pMultiStatus; - pMultiStatus = pMultiStatus->pNext; - - if (pCurStatus) { - free(pCurStatus); - pCurStatus = NULL; - } - } - - pAttrib->pMultiStatus = NULL; - } - - - MSG_END(); - - return true; -} - -bool MsgFreeBody(MsgBody *pBody, int type) -{ - MSG_DEBUG("_MsgFreeBody: S T A R T !!! \n") ; - - if (pBody == NULL) { - MSG_DEBUG("_MsgFreeBody: pBody == NULL \n" ); - MSG_DEBUG("_MsgFreeBody: E N D (End)!!! \n") ; - - return false; - } - - switch (type) { - case MIME_MULTIPART_REPORT: - case MIME_APPLICATION_VND_OMA_DRM_MESSAGE: - case MIME_APPLICATION_VND_WAP_MULTIPART_MIXED: - case MIME_APPLICATION_VND_WAP_MULTIPART_RELATED: - case MIME_APPLICATION_VND_WAP_MULTIPART_ASTERIC: - case MIME_MULTIPART_MIXED: - case MIME_MULTIPART_RELATED: - case MIME_MULTIPART_ALTERNATIVE: - case MIME_APPLICATION_VND_WAP_MULTIPART_ALTERNATIVE: - { - MsgMultipart *pMulti = pBody->body.pMultipart; - MsgMultipart *pCurrPart = NULL; - MsgBody *pPresentation = pBody->pPresentationBody; - while (pMulti != NULL) { - pCurrPart = pMulti; - - pMulti = pMulti->pNext; - if (pCurrPart) { -#ifdef __SUPPORT_DRM__ - MsgFreeDRMInfo(&pCurrPart->type.drmInfo); -#endif - - if (pCurrPart->pBody) { - if (pCurrPart->pBody->body.pBinary) { - free(pCurrPart->pBody->body.pBinary); - pCurrPart->pBody->body.pBinary = NULL; - } - free(pCurrPart->pBody); - pCurrPart->pBody = NULL; - } - free(pCurrPart); - pCurrPart = NULL; - } - } - - pBody->body.pMultipart = NULL; - - if (pPresentation) { - if (pPresentation->body.pText) { - free(pPresentation->body.pText); - pPresentation->body.pText = NULL; - } - free(pPresentation); - pBody->pPresentationBody = NULL; - } - - __MsgInitMsgType(&pBody->presentationType); - - break; - } - - default: - /* Any single part */ - - if (pBody->body.pBinary) { - free(pBody->body.pBinary); - pBody->body.pBinary = NULL; - } - - break; - } - - MSG_DEBUG("_MsgFreeBody: E N D (Successfully) !!! \n") ; - - return true; - -} static bool __MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody) { @@ -5622,9 +5353,9 @@ static bool __MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody) if (pRemoveList) { #ifdef __SUPPORT_DRM__ - MsgFreeDRMInfo(&pRemoveList->type.drmInfo); + MmsReleaseMsgDRMInfo(&pRemoveList->type.drmInfo); #endif - MsgFreeBody(pRemoveList->pBody, pRemoveList->type.type); + MmsReleaseMsgBody(pRemoveList->pBody, pRemoveList->type.type); free(pRemoveList->pBody); free(pRemoveList); @@ -5640,7 +5371,7 @@ static bool __MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody) if (pSelectedPart != NULL) { #ifdef __SUPPORT_DRM__ - MsgFreeDRMInfo(&pSelectedPart->type.drmInfo); + MmsReleaseMsgDRMInfo(&pSelectedPart->type.drmInfo); #endif if (pSelectedPart->pBody != NULL) { @@ -5696,7 +5427,7 @@ static bool __MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody) if (pSelectedPart) { #ifdef __SUPPORT_DRM__ - MsgFreeDRMInfo(&pSelectedPart->type.drmInfo); + MmsReleaseMsgDRMInfo(&pSelectedPart->type.drmInfo); #endif free(pSelectedPart->pBody); free(pSelectedPart); @@ -5704,7 +5435,7 @@ static bool __MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody) pSelectedPart = pTmpMultipart; } else if (__MsgIsMultipartRelated(pSelectedPart->type.type) && pPrevPart != NULL) { pPrevPart->pNext = pTmpMultipart = pSelectedPart->pNext; - MsgFreeBody(pSelectedPart->pBody, pSelectedPart->type.type); + MmsReleaseMsgBody(pSelectedPart->pBody, pSelectedPart->type.type); free(pSelectedPart->pBody); free(pSelectedPart); @@ -5769,7 +5500,7 @@ static bool __MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody) pPartType->type = pSelectedPart->type.type; #ifdef __SUPPORT_DRM__ - MsgFreeDRMInfo(&pSelectedPart->type.drmInfo); + MmsReleaseMsgDRMInfo(&pSelectedPart->type.drmInfo); #endif free(pSelectedPart->pBody); free(pSelectedPart); @@ -5830,9 +5561,9 @@ static bool __MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody) while (pTmpMultipart) { #ifdef __SUPPORT_DRM__ - MsgFreeDRMInfo(&pTmpMultipart->type.drmInfo); + MmsReleaseMsgDRMInfo(&pTmpMultipart->type.drmInfo); #endif - MsgFreeBody(pTmpMultipart->pBody, pTmpMultipart->type.type); + MmsReleaseMsgBody(pTmpMultipart->pBody, pTmpMultipart->type.type); pNextRemovePart = pTmpMultipart->pNext; free(pTmpMultipart->pBody); @@ -5850,7 +5581,7 @@ static bool __MsgResolveNestedMultipart(MsgType *pPartType, MsgBody *pPartBody) if (pSelectedPart != NULL) { #ifdef __SUPPORT_DRM__ - MsgFreeDRMInfo(&pSelectedPart->type.drmInfo); + MmsReleaseMsgDRMInfo(&pSelectedPart->type.drmInfo); #endif if (pSelectedPart->pBody != NULL) { free(pSelectedPart->pBody); @@ -6028,6 +5759,9 @@ static int __MsgConvertCharToInt(char ch) static bool __MsgCopyNestedMsgType(MsgType *pMsgType1, MsgType *pMsgType2) { + if(!pMsgType1 || !pMsgType2) + return false; + if (pMsgType1->section == INVALID_HOBJ) pMsgType1->section = pMsgType2->section; @@ -7069,7 +6803,6 @@ __CATCH: static bool __MmsMultipartSaveAsTempFile(MsgType *pPartType, MsgBody *pPartBody, char *pszMailboxPath, char *pszMsgFilename, int index, bool bSave) { FILE *pFile = NULL; -// char *pExt = NULL; char szFileName[MSG_FILENAME_LEN_MAX+1] = {0, }; // file name of temp file char szFullPath[MSG_FILEPATH_LEN_MAX] = {0, }; // full absolute path of temp file. @@ -7538,13 +7271,14 @@ static bool __MsgMakeFileName(int iMsgType, char *szFileName, MsgDrmType drmType strncpy(szText, szTempFileName, pExt+1 - szFileName); } } else { - if (strrchr(szTempFileName, '.')) + pExt = strrchr(szTempFileName, '.'); + if (pExt == NULL) { + memset(szText, 0, MSG_FILENAME_LEN_MAX+1); + strncpy(szText, szTempFileName, MSG_FILENAME_LEN_MAX - 1); + strcat(szText, "."); + } else { return true; - - memset(szText, 0, MSG_FILENAME_LEN_MAX+1); - strncpy(szText, szTempFileName, MSG_FILENAME_LEN_MAX - 1); - //temporary commented to save file as original name. - pExt = strrchr(szFileName, '.'); + } } } else { if (nUntitleIndex >= 1) { @@ -7645,7 +7379,7 @@ bool MmsGetMediaPartHeader(int index, MsgType *pHeader) MmsPluginStorage::instance()->getMmsMessage(&pMsg); - __MsgInitMsgType(pHeader); + MmsInitMsgType(pHeader); /* Requires header of non-presentation */ diff --git a/plugin/mms_plugin/MmsPluginInternal.cpp b/plugin/mms_plugin/MmsPluginInternal.cpp index 2c0bfa8..ac797e5 100755 --- a/plugin/mms_plugin/MmsPluginInternal.cpp +++ b/plugin/mms_plugin/MmsPluginInternal.cpp @@ -378,9 +378,9 @@ void MmsPluginInternal::processSendConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTranQEn MmsPluginStorage::instance()->getMmsMessage(&pMsg); MmsInitHeader(); #ifdef __SUPPORT_DRM__ - MsgFreeDRMInfo(&pMsg->msgType.drmInfo); + MmsReleaseMsgDRMInfo(&pMsg->msgType.drmInfo); #endif - MsgFreeBody(&pMsg->msgBody, pMsg->msgType.type); + MmsReleaseMsgBody(&pMsg->msgBody, pMsg->msgType.type); MSG_END(); @@ -536,7 +536,7 @@ void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTra } if (partHeader.contentSize > 0) { - char szBuf[MSG_FILEPATH_LEN_MAX]; + char szBuf[MSG_FILEPATH_LEN_MAX + 1]; strcpy((char *)szBuf, partHeader.param.szFileName); sprintf(partHeader.param.szFileName, MSG_DATA_PATH"%s", szBuf); @@ -580,9 +580,9 @@ void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTra pStorage->getMmsMessage(&pMsg); MmsInitHeader(); #ifdef __SUPPORT_DRM__ - MsgFreeDRMInfo(&pMsg->msgType.drmInfo); + MmsReleaseMsgDRMInfo(&pMsg->msgType.drmInfo); #endif - MsgFreeBody(&pMsg->msgBody, pMsg->msgType.type); + MmsReleaseMsgBody(&pMsg->msgBody, pMsg->msgType.type); MSG_END(); } diff --git a/plugin/mms_plugin/MmsPluginSmil.cpp b/plugin/mms_plugin/MmsPluginSmil.cpp index 16ef186..3011fdc 100755 --- a/plugin/mms_plugin/MmsPluginSmil.cpp +++ b/plugin/mms_plugin/MmsPluginSmil.cpp @@ -819,37 +819,16 @@ int MmsSmilGetMediaSrcForNormalMsg(char *szOutbuf, char *szInBuf, MsgMultipart * if (strcasecmp(szContentID, szInBuf) == 0) { strcpy(szOutbuf, pPart->type.param.szFileName); - MSG_DEBUG("match with szContentID."); + MSG_DEBUG("match with szContentID"); + goto RETURN; + } else if (strcasecmp(szContentLI, szInBuf) == 0) { + strcpy(szOutbuf, pPart->type.param.szFileName); + MSG_DEBUG("match with szContentLocation"); + goto RETURN; + } else if (strcasecmp(pPart->type.param.szName, szInBuf) == 0) { + strcpy(szOutbuf, pPart->type.param.szFileName); + MSG_DEBUG("match with Parameter Name"); goto RETURN; - } else { - char *szInFileName = strrchr(szInBuf, '/'); - - if (szInFileName == NULL) { - szInFileName = szInBuf; - } else - szInFileName++; - - if (strcasecmp(szContentLI, szInFileName) == 0) { - strcpy(szOutbuf, pPart->type.param.szFileName); - MSG_DEBUG("match with szContentLI."); - goto RETURN; - } else if (strcasecmp(pPart->type.param.szName, szInBuf) == 0) { - strcpy(szOutbuf, pPart->type.param.szFileName); - MSG_DEBUG("match with pPart->type.param.szName."); - goto RETURN; - } else if (strlen(szContentID) > 4) { - if (strcasecmp(strtok(szContentID, "."), strtok(szInBuf, ".")) == 0) { - strcpy(szOutbuf, pPart->type.param.szFileName); - MSG_DEBUG("only name is match with szContentID."); - goto RETURN; - } - } else if (strlen(szContentLI) > 4) { - if (strcasecmp(strtok(szContentLI, "."), strtok(szInBuf, ".")) == 0) { - strcpy(szOutbuf, pPart->type.param.szFileName); - MSG_DEBUG("only name is match with szContentLI."); - goto RETURN; - } - } } nPart++; diff --git a/plugin/mms_plugin/MmsPluginStorage.cpp b/plugin/mms_plugin/MmsPluginStorage.cpp index 7c56c97..45f0c86 100755 --- a/plugin/mms_plugin/MmsPluginStorage.cpp +++ b/plugin/mms_plugin/MmsPluginStorage.cpp @@ -92,9 +92,9 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I MMS_MESSAGE_DATA_S mmsMsgData; bzero(&mmsMsgData,sizeof(MMS_MESSAGE_DATA_S)); if (MmsComposeMessage(&mmsMsg, pMsgInfo, pSendOptInfo, &mmsMsgData, pFileData) != true) { - MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); + MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type); - MsgFreeAttrib(&mmsMsg.mmsAttrib); + MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib); __MmsReleaseMmsLists(&mmsMsgData); THROW(MsgException::MMS_PLG_ERROR, "MMS Message Compose Error"); @@ -109,8 +109,8 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I snprintf((char *)pMsgInfo->msgData, MAX_MSG_DATA_LEN+1, MSG_DATA_PATH"%d.mms", pMsgInfo->msgId); if (addMmsMsgToDB(&mmsMsg, pMsgInfo, _MsgMmsGetAttachCount(&mmsMsgData)) != MSG_SUCCESS) { - MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); - MsgFreeAttrib(&mmsMsg.mmsAttrib); + MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type); + MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib); __MmsReleaseMmsLists(&mmsMsgData); THROW(MsgException::MMS_PLG_ERROR, "MMS Stroage Error"); @@ -122,15 +122,15 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I pFile = MsgOpenMMSFile(fileName); if (!pFile) { - MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); - MsgFreeAttrib(&mmsMsg.mmsAttrib); + MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type); + MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib); __MmsReleaseMmsLists(&mmsMsgData); THROW(MsgException::MMS_PLG_ERROR, "MMS File open Error"); } if (fchmod(fileno(pFile), file_mode) < 0) { - MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); - MsgFreeAttrib(&mmsMsg.mmsAttrib); + MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type); + MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib); __MmsReleaseMmsLists(&mmsMsgData); MsgCloseFile(pFile); @@ -138,8 +138,8 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I } if (MmsEncodeSendReq(pFile, &mmsMsg) != true) { - MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); - MsgFreeAttrib(&mmsMsg.mmsAttrib); + MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type); + MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib); __MmsReleaseMmsLists(&mmsMsgData); MsgCloseFile(pFile); @@ -159,8 +159,8 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I pMsgInfo->dataSize = size; - MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); - MsgFreeAttrib(&mmsMsg.mmsAttrib); + MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type); + MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib); __MmsReleaseMmsLists(&mmsMsgData); } else if (pMsgInfo->msgType.subType == MSG_NOTIFICATIONIND_MMS) { @@ -170,7 +170,7 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I //Need to store mms specific data (contents location, TrID, ExpiryTime, Delivery Report, message ID) if (addMmsMsgToDB(&mmsMsg, pMsgInfo) != MSG_SUCCESS) { - MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); + MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type); THROW(MsgException::MMS_PLG_ERROR, "MMS Stroage Error"); } } else if (pMsgInfo->msgType.subType == MSG_SENDCONF_MMS || pMsgInfo->msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS) { @@ -217,14 +217,14 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I } if (addMmsMsgToDB(pMsg, pMsgInfo) != MSG_SUCCESS) { - MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); + MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type); THROW(MsgException::MMS_PLG_ERROR, "MMS Stroage Error"); } memset(pMsgInfo->msgData, 0, MAX_MSG_DATA_LEN + 1); strcpy((char *)pMsgInfo->msgData,szTemp); - MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); + MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type); } else if (pMsgInfo->msgType.subType == MSG_READREPLY_MMS || pMsgInfo->msgType.subType == MSG_READRECIND_MMS) { MSG_DEBUG("######## MmsPlgAddMessage -> MSG_READREPLY_MMS || MSG_READRECIND_MMS ###########"); @@ -246,8 +246,8 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I MmsComposeReadReportMessage(&mmsMsg, pMsgInfo, selectedMsgId); if (addMmsMsgToDB(&mmsMsg, pMsgInfo) != MSG_SUCCESS) { - MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); - MsgFreeAttrib(&mmsMsg.mmsAttrib); + MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type); + MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib); THROW(MsgException::MMS_PLG_ERROR, "MMS Stroage Error"); } @@ -255,8 +255,8 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I snprintf(filePath, MAX_FULL_PATH_SIZE+1, MSG_DATA_PATH"%d", mmsMsg.msgID); pFile = MsgOpenMMSFile(filePath); if (!pFile) { - MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); - MsgFreeAttrib(&mmsMsg.mmsAttrib); + MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type); + MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib); MsgCloseFile(pFile); pFile = NULL; @@ -264,8 +264,8 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I } if (fchmod(fileno(pFile), file_mode) < 0) { - MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); - MsgFreeAttrib(&mmsMsg.mmsAttrib); + MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type); + MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib); MsgCloseFile(pFile); pFile = NULL; @@ -275,7 +275,7 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I if (version == 0x90) { MSG_DEBUG("### version 1.0 ###"); if (MmsEncodeReadReport10(pFile, &mmsMsg, readStatus) != true) { - MsgFreeAttrib(&mmsMsg.mmsAttrib); + MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib); MsgCloseFile(pFile); pFile = NULL; @@ -284,7 +284,7 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I } else { MSG_DEBUG("### version 1.1 ###"); if (MmsEncodeReadReport11(pFile, &mmsMsg, readStatus) != true) { - MsgFreeAttrib(&mmsMsg.mmsAttrib); + MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib); MsgCloseFile(pFile); pFile = NULL; @@ -296,9 +296,9 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I MsgCloseFile(pFile); pFile = NULL; - MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); + MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type); - MsgFreeAttrib(&mmsMsg.mmsAttrib); + MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib); } else if (pMsgInfo->msgType.subType == MSG_FORWARD_MMS) { MSG_DEBUG("######## MmsPlgAddMessage -> MSG_FORWARD_MMS ###########"); @@ -309,8 +309,8 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I MMS_MESSAGE_DATA_S mmsMsgData; if (MmsComposeMessage(&mmsMsg, pMsgInfo, pSendOptInfo, &mmsMsgData, pFileData) != true) { - MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); - MsgFreeAttrib(&mmsMsg.mmsAttrib); + MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type); + MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib); __MmsReleaseMmsLists(&mmsMsgData); THROW(MsgException::MMS_PLG_ERROR, "MMS Message Compose Error"); @@ -321,8 +321,8 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I snprintf((char *)pMsgInfo->msgData, MAX_MSG_DATA_LEN + 1, MSG_DATA_PATH"%d.mms", pMsgInfo->msgId); if (addMmsMsgToDB(&mmsMsg, pMsgInfo, _MsgMmsGetAttachCount(&mmsMsgData)) != MSG_SUCCESS) { - MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); - MsgFreeAttrib(&mmsMsg.mmsAttrib); + MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type); + MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib); __MmsReleaseMmsLists(&mmsMsgData); THROW(MsgException::MMS_PLG_ERROR, "MMS Stroage Error"); @@ -334,8 +334,8 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I pFile = MsgOpenMMSFile(filePath); if (!pFile) { - MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); - MsgFreeAttrib(&mmsMsg.mmsAttrib); + MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type); + MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib); __MmsReleaseMmsLists(&mmsMsgData); MsgCloseFile(pFile); pFile = NULL; @@ -344,8 +344,8 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I } if (fchmod(fileno(pFile), file_mode) < 0) { - MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); - MsgFreeAttrib(&mmsMsg.mmsAttrib); + MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type); + MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib); __MmsReleaseMmsLists(&mmsMsgData); MsgCloseFile(pFile); pFile = NULL; @@ -354,8 +354,8 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I } if (MmsEncodeSendReq(pFile, &mmsMsg) != true) { - MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); - MsgFreeAttrib(&mmsMsg.mmsAttrib); + MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type); + MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib); __MmsReleaseMmsLists(&mmsMsgData); MsgCloseFile(pFile); pFile = NULL; @@ -366,8 +366,8 @@ void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_I MsgCloseFile(pFile); pFile = NULL; - MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); - MsgFreeAttrib(&mmsMsg.mmsAttrib); + MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type); + MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib); __MmsReleaseMmsLists(&mmsMsgData); } @@ -460,7 +460,7 @@ msg_error_t MmsPluginStorage::plgGetMmsMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SEN MsgType partHeader; MmsAttrib pMmsAttrib; - char szBuf[MSG_FILEPATH_LEN_MAX] = {0, }; + char szBuf[MSG_FILEPATH_LEN_MAX + 1] = {0, }; bool bMultipartRelated = false; if (pSendOptInfo != NULL) { @@ -576,9 +576,9 @@ msg_error_t MmsPluginStorage::plgGetMmsMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SEN if (partHeader.contentSize > 0) { if (!strcasecmp(partHeader.param.szFileName, "cid:")) { - strncpy((char *)szBuf, &partHeader.param.szFileName[4], MSG_FILEPATH_LEN_MAX - 1); + strncpy((char *)szBuf, &partHeader.param.szFileName[4], MSG_FILEPATH_LEN_MAX); } else { - strcpy((char *)szBuf, partHeader.param.szFileName); + strncpy((char *)szBuf, partHeader.param.szFileName, MSG_FILEPATH_LEN_MAX); } sprintf(partHeader.param.szFileName, MSG_DATA_PATH"%s", szBuf); @@ -613,9 +613,9 @@ msg_error_t MmsPluginStorage::plgGetMmsMessage(MSG_MESSAGE_INFO_S *pMsg, MSG_SEN MmsInitHeader(); MmsUnregisterDecodeBuffer(); #ifdef __SUPPORT_DRM__ - MsgFreeDRMInfo(&pStoMmsMsg->msgType.drmInfo); + MmsReleaseMsgDRMInfo(&pStoMmsMsg->msgType.drmInfo); #endif - MsgFreeBody(&pStoMmsMsg->msgBody, pStoMmsMsg->msgType.type); + MmsReleaseMsgBody(&pStoMmsMsg->msgBody, pStoMmsMsg->msgType.type); pMsg->dataSize = nSize; @@ -638,9 +638,9 @@ L_CATCH: MmsUnregisterDecodeBuffer(); #ifdef __SUPPORT_DRM__ - MsgFreeDRMInfo(&pMsg->msgType.drmInfo); + MmsReleaseMsgDRMInfo(&pMsg->msgType.drmInfo); #endif - MsgFreeBody(&pMsg->msgBody, pMsg->msgType.type); + MmsReleaseMsgBody(&pMsg->msgBody, pMsg->msgType.type); return MSG_ERR_STORAGE_ERROR; } @@ -673,8 +673,8 @@ msg_error_t MmsPluginStorage::updateMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SE MMS_MESSAGE_DATA_S mmsMsgData; if (MmsComposeMessage(&mmsMsg, pMsgInfo, pSendOptInfo, &mmsMsgData, pFileData) != true) { - MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); - MsgFreeAttrib(&mmsMsg.mmsAttrib); + MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type); + MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib); __MmsReleaseMmsLists(&mmsMsgData); THROW(MsgException::MMS_PLG_ERROR, "MMS Message Compose Error"); @@ -685,8 +685,8 @@ msg_error_t MmsPluginStorage::updateMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SE pFile = MsgOpenMMSFile(filePath); if (MmsEncodeSendReq(pFile, &mmsMsg) != true) { - MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); - MsgFreeAttrib(&mmsMsg.mmsAttrib); + MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type); + MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib); __MmsReleaseMmsLists(&mmsMsgData); MsgCloseFile(pFile); @@ -695,8 +695,8 @@ msg_error_t MmsPluginStorage::updateMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SE MsgCloseFile(pFile); - MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); - MsgFreeAttrib(&mmsMsg.mmsAttrib); + MmsReleaseMsgBody(&mmsMsg.msgBody, mmsMsg.msgType.type); + MmsReleaseMmsAttrib(&mmsMsg.mmsAttrib); __MmsReleaseMmsLists(&mmsMsgData); diff --git a/plugin/mms_plugin/MmsPluginUserAgent.cpp b/plugin/mms_plugin/MmsPluginUserAgent.cpp index d3889c4..5c64475 100755 --- a/plugin/mms_plugin/MmsPluginUserAgent.cpp +++ b/plugin/mms_plugin/MmsPluginUserAgent.cpp @@ -657,9 +657,9 @@ ERR_MMS_UA_PROCESS_CONF: MmsUnregisterDecodeBuffer(); #ifdef __SUPPORT_DRM__ - MsgFreeDRMInfo(&pMsg->msgType.drmInfo); + MmsReleaseMsgDRMInfo(&pMsg->msgType.drmInfo); #endif - MsgFreeBody(&pMsg->msgBody, pMsg->msgType.type); + MmsReleaseMsgBody(&pMsg->msgBody, pMsg->msgType.type); return false; } diff --git a/plugin/mms_plugin/MmsPluginUtil.cpp b/plugin/mms_plugin/MmsPluginUtil.cpp index f23605c..12b1858 100755 --- a/plugin/mms_plugin/MmsPluginUtil.cpp +++ b/plugin/mms_plugin/MmsPluginUtil.cpp @@ -19,6 +19,8 @@ #include #include #include +#include +#include #include "MsgUtilFile.h" #include "MmsPluginDebug.h" #include "MmsPluginUtil.h" @@ -337,7 +339,7 @@ char *MsgStrNCopy(const char *string, int length) if (string) { pDst = (char *)malloc(1 + length); if (pDst == NULL) { - MSG_DEBUG("MsgStrNCopy: pDst MemAlloc Fail \n"); + MSG_DEBUG("pDst MemAlloc Fail \n"); return NULL; } @@ -368,3 +370,38 @@ bool MsgConvertCharToHex(char pSrc, char *pDest) return true; } + + +FILE *MmsFileOpen(char *pFileName) +{ + int len; + mode_t file_mode = (S_IRUSR | S_IWUSR); + + if (!pFileName) { + MSG_DEBUG("pFileName NULL: %s", strerror(errno)); + return NULL; + } + + MSG_DEBUG("pFileName = %s", pFileName); + + FILE *pFile = MsgOpenFile(pFileName, "wb+"); + + if (pFile == NULL) { + MSG_FATAL("File Open Error: %s", strerror(errno)); + return NULL; + } + + if (MsgFseek(pFile, 0L, SEEK_CUR) < 0) { + MsgCloseFile(pFile); + MSG_DEBUG("File Read Error: %s", strerror(errno)); + return NULL; + } + + if (fchmod(fileno(pFile), file_mode) < 0) { + MsgCloseFile(pFile); + MSG_DEBUG("File chmod Error: %s", strerror(errno)); + return NULL; + } + + return pFile; +} diff --git a/plugin/mms_plugin/include/MmsPluginCodecCommon.h b/plugin/mms_plugin/include/MmsPluginCodecCommon.h index 75037eb..4137ddd 100755 --- a/plugin/mms_plugin/include/MmsPluginCodecCommon.h +++ b/plugin/mms_plugin/include/MmsPluginCodecCommon.h @@ -50,7 +50,11 @@ bool MmsInitMsgAttrib(MmsAttrib *pAttrib); #ifdef __SUPPORT_DRM__ bool MmsInitMsgDRMInfo(MsgDRMInfo *pMsgDrmInfo); +void MmsReleaseMsgDRMInfo(MsgDRMInfo *pDrmInfo); #endif//__SUPPORT_DRM__ +bool MmsReleaseMsgBody(MsgBody *pBody, int type); +bool MmsReleaseMmsAttrib(MmsAttrib *pAttrib); +void MmsReleaseMmsMsg(MmsMsg *pMmsMsg); #endif //MMS_PLUGIN_CODEC_COMMON_H diff --git a/plugin/mms_plugin/include/MmsPluginDecode.h b/plugin/mms_plugin/include/MmsPluginDecode.h index 0e37b5a..ee8a3e4 100755 --- a/plugin/mms_plugin/include/MmsPluginDecode.h +++ b/plugin/mms_plugin/include/MmsPluginDecode.h @@ -107,8 +107,6 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength); bool MmsBinaryDecodeMsgBody(FILE *pFile, char *szFilePath, int totalLength); bool MmsReadMsgBody(msg_message_id_t msgID, bool bSavePartsAsTempFiles, bool bRetrieved, char *retrievedPath); -bool MsgFreeBody(MsgBody *pBody, int type); -bool MsgFreeAttrib(MmsAttrib *pAttrib); char *MsgChangeHexString(char *pOrg); char *MsgResolveContentURI(char *szSrc); @@ -124,7 +122,6 @@ bool MmsGetMediaPartHeader(int index, MsgType *pHeader); bool MmsGetMsgAttrib(MmsMsgID msgID, MmsAttrib *pAttrib); #ifdef __SUPPORT_DRM__ -void MsgFreeDRMInfo(MsgDRMInfo *pDrmInfo); bool MsgCopyDrmInfo(MsgType *pPartType); bool MmsDrm2ConvertMsgBody(char *szOriginFilePath); bool MmsDrm2ReadMsgConvertedBody(MSG_MESSAGE_INFO_S *pMsg, bool bSavePartsAsTempFiles, bool bRetrieved, char *retrievedPath); diff --git a/plugin/mms_plugin/include/MmsPluginUtil.h b/plugin/mms_plugin/include/MmsPluginUtil.h index d7348d6..b1ac716 100755 --- a/plugin/mms_plugin/include/MmsPluginUtil.h +++ b/plugin/mms_plugin/include/MmsPluginUtil.h @@ -17,6 +17,8 @@ #ifndef MMS_PLUGIN_UTIL_H #define MMS_PLUGIN_UTIL_H +#include + bool makeImageThumbnail(char *srcPath, char *dstPath); bool makeVideoThumbnail(char *srcPath, char *dstPath); @@ -29,5 +31,5 @@ char *MsgStrCopy(const char *string); char *MsgStrNCopy(const char *string, int length); int MsgStrlen(char *pStr); bool MsgConvertCharToHex(char pSrc, char *pDest); - +FILE *MmsFileOpen(char *pFileName); #endif //MMS_PLUGIN_UTIL_H -- cgit v1.2.3