diff options
Diffstat (limited to 'plugin')
42 files changed, 726 insertions, 656 deletions
diff --git a/plugin/mms_plugin/CMakeLists.txt b/plugin/mms_plugin/CMakeLists.txt index 0d8f267..d3ffda1 100755 --- a/plugin/mms_plugin/CMakeLists.txt +++ b/plugin/mms_plugin/CMakeLists.txt @@ -8,7 +8,6 @@ IF("${CMAKE_BUILD_TYPE}" STREQUAL "") ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "") MESSAGE("Build type: ${CMAKE_BUILD_TYPE}") - ########################################################## # Define MMS Plugin ########################################################## diff --git a/plugin/mms_plugin/MmsPluginAppBase.cpp b/plugin/mms_plugin/MmsPluginAppBase.cpp index ee87255..11e4a23 100755 --- a/plugin/mms_plugin/MmsPluginAppBase.cpp +++ b/plugin/mms_plugin/MmsPluginAppBase.cpp @@ -26,7 +26,10 @@ msg_error_t MmsMakePreviewInfo(int msgId, MMS_MESSAGE_DATA_S *pMmsMsg, bool allow_malware, const char *raw_filepath); -MmsPluginAppBase::MmsPluginAppBase(){} +MmsPluginAppBase::MmsPluginAppBase() +{ + memset(&mmsMsgData, 0x00, sizeof(mmsMsgData)); +} MmsPluginAppBase::MmsPluginAppBase(MMS_DATA_S *pMmsData) { @@ -80,7 +83,7 @@ void MmsPluginAppBase::getFirstPageTextFilePath(char *textBuf, int textBufSize) pMedia = _MsgMmsGetMedia(pPage, j); - if (pMedia->mediatype == MMS_SMIL_MEDIA_TEXT) { + if (pMedia && pMedia->mediatype == MMS_SMIL_MEDIA_TEXT) { MimeType mimeType = MIME_UNKNOWN; diff --git a/plugin/mms_plugin/MmsPluginCodecCommon.cpp b/plugin/mms_plugin/MmsPluginCodecCommon.cpp index a307588..c8078d2 100755 --- a/plugin/mms_plugin/MmsPluginCodecCommon.cpp +++ b/plugin/mms_plugin/MmsPluginCodecCommon.cpp @@ -700,11 +700,13 @@ int extract_encoded_word_param(char *encoded_word, char **charset, char **encod char_set = (char*)calloc(1, q1_ptr - (start_ptr + 2) + 1); - strncpy(char_set, (char*)((start_ptr + 2)), q1_ptr - (start_ptr + 2)); - - MSG_DEBUG("character set [%s][%d]", char_set, strlen(char_set)); - - + if (char_set) { + strncpy(char_set, (char*)((start_ptr + 2)), q1_ptr - (start_ptr + 2)); + MSG_DEBUG("character set [%s][%d]", char_set, strlen(char_set)); + } else { + MSG_DEBUG("fail to calloc"); + goto __CATCH; + } } else { MSG_DEBUG("character set is NULL"); goto __CATCH; @@ -729,7 +731,8 @@ int extract_encoded_word_param(char *encoded_word, char **charset, char **encod //extract encoded text if (end_ptr - q2_ptr > 1) { l_encoded_text = (char*)calloc(1, end_ptr - q2_ptr); - + if (l_encoded_text == NULL) + goto __CATCH; strncpy(l_encoded_text, (char*)(q2_ptr + 1), end_ptr - q2_ptr -1); MSG_DEBUG("encoded text [%s][%d]", l_encoded_text, strlen(l_encoded_text)); @@ -1492,7 +1495,7 @@ bool MmsInitMsgBody(MsgBody *pMsgBody) MmsInitMsgType(&pMsgBody->presentationType); pMsgBody->pPresentationBody = NULL; - memset(pMsgBody->szOrgFilePath, 0, MSG_FILEPATH_LEN_MAX); + memset(pMsgBody->szOrgFilePath, 0, MSG_FILEPATH_LEN_MAX + 1); return true; } diff --git a/plugin/mms_plugin/MmsPluginComposer.cpp b/plugin/mms_plugin/MmsPluginComposer.cpp index f83e94b..dea1b2f 100755 --- a/plugin/mms_plugin/MmsPluginComposer.cpp +++ b/plugin/mms_plugin/MmsPluginComposer.cpp @@ -64,8 +64,10 @@ void MmsPluginComposer::composeSendReq(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDING pMmsData->header = MsgMmsCreateHeader(); } - composeSendReqHeader(pMsgInfo, pSendOptInfo, pMmsData); - //TODO:: apply MmsReplaceNonAsciiUtf8 to all multipart FileName; + if (pMmsData->header) { + composeSendReqHeader(pMsgInfo, pSendOptInfo, pMmsData); + //TODO:: apply MmsReplaceNonAsciiUtf8 to all multipart FileName; + } int len = g_list_length(pMmsData->multipartlist); @@ -132,7 +134,7 @@ bool composeSendReqHeader(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *p MmsTimeStruct deliveryTime; MmsMsgClass msgClass; - struct tm *timeInfo = NULL; + struct tm timeInfo; time_t RawTime = 0; time_t nTimeInSecs = 0; @@ -180,8 +182,8 @@ bool composeSendReqHeader(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *p //set Header time(&RawTime); - timeInfo = localtime(&RawTime); - nTimeInSecs = mktime(timeInfo); + localtime_r(&RawTime, &timeInfo); + nTimeInSecs = mktime(&timeInfo); pHeaderData->date = nTimeInSecs; pHeaderData->bDeliveryReport = bAskDeliveryReport; diff --git a/plugin/mms_plugin/MmsPluginConnManWrapper.cpp b/plugin/mms_plugin/MmsPluginConnManWrapper.cpp index 59fc773..bb02aa6 100755 --- a/plugin/mms_plugin/MmsPluginConnManWrapper.cpp +++ b/plugin/mms_plugin/MmsPluginConnManWrapper.cpp @@ -410,6 +410,7 @@ MmsPluginCmAgent::MmsPluginCmAgent() MSG_BEGIN(); isCmOpened = false; + waitProfileOpen = false; home_url = NULL; interface_name = NULL; diff --git a/plugin/mms_plugin/MmsPluginDecode.cpp b/plugin/mms_plugin/MmsPluginDecode.cpp index e915561..d204d11 100755 --- a/plugin/mms_plugin/MmsPluginDecode.cpp +++ b/plugin/mms_plugin/MmsPluginDecode.cpp @@ -478,10 +478,10 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength) goto __CATCH; } - pLimitData = (char *)malloc(MSG_LOCALE_SUBJ_LEN + 1); + pLimitData = (char *)calloc(1, MSG_LOCALE_SUBJ_LEN + 1); if (pLimitData == NULL) { - MSG_DEBUG("pLimitData malloc fail"); + MSG_DEBUG("pLimitData calloc fail"); goto __CATCH; } @@ -530,11 +530,11 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength) goto __CATCH; } } else { - mmsHeader.pFrom = (MsgHeaderAddress *)malloc(sizeof(MsgHeaderAddress)); + mmsHeader.pFrom = (MsgHeaderAddress *)calloc(1, sizeof(MsgHeaderAddress)); if (mmsHeader.pFrom == NULL) goto __CATCH; - mmsHeader.pFrom->szAddr = (char *)malloc(1); + mmsHeader.pFrom->szAddr = (char *)calloc(1, 1); if (mmsHeader.pFrom->szAddr == NULL) { free(mmsHeader.pFrom); mmsHeader.pFrom = NULL; @@ -633,7 +633,7 @@ bool MmsBinaryDecodeMsgHeader(FILE *pFile, int totalLength) goto __CATCH; } - MSG_SEC_INFO("Date = [%u][%s]", mmsHeader.date, ctime((const time_t *)&mmsHeader.date)); + MSG_SEC_INFO("Date = [%u][%d]", mmsHeader.date, (const time_t *)&mmsHeader.date); break; case MMS_CODE_DELIVERYREPORT: @@ -1088,7 +1088,7 @@ bool MmsBinaryDecodeMsgBody(FILE *pFile, char *szFilePath, int totalLength) int offset = 0; if (szFilePath != NULL) - strncpy(mmsHeader.msgType.szOrgFilePath, szFilePath , strlen(szFilePath)); + snprintf(mmsHeader.msgType.szOrgFilePath, sizeof(mmsHeader.msgType.szOrgFilePath), "%s", szFilePath); mmsHeader.msgType.offset = __MmsGetDecodeOffset() - 1; // + Content-Type code value @@ -1352,15 +1352,19 @@ static bool __MmsBinaryDecodeParameter(FILE *pFile, MsgType *pMsgType, int value strncpy(pMsgType->param.szBoundary, szTypeValue, MSG_BOUNDARY_LEN); #ifdef FEATURE_JAVA_MMS } else if (strcasecmp(szTypeString, "Application-ID") == 0) { - pMsgType->param.szApplicationID = (char*) malloc(textLength + 1); - memset(pMsgType->param.szApplicationID, 0, textLength + 1); - strncpy(pMsgType->param.szApplicationID, szTypeValue, textLength); - MSG_SEC_DEBUG("Application-ID:%s",pMsgType->param.szApplicationID); + pMsgType->param.szApplicationID = (char*) calloc(1, textLength + 1); + if (pMsgType->param.szApplicationID) { + memset(pMsgType->param.szApplicationID, 0, textLength + 1); + strncpy(pMsgType->param.szApplicationID, szTypeValue, textLength); + MSG_SEC_DEBUG("Application-ID:%s",pMsgType->param.szApplicationID); + } } else if (strcasecmp(szTypeString,"Reply-To-Application-ID") == 0) { - pMsgType->param.szReplyToApplicationID= (char*) malloc(textLength + 1); - memset(pMsgType->param.szReplyToApplicationID, 0, textLength + 1); - strncpy(pMsgType->param.szReplyToApplicationID, szTypeValue, textLength); - MSG_SEC_DEBUG("ReplyToApplication-ID:%s",pMsgType->param.szReplyToApplicationID); + pMsgType->param.szReplyToApplicationID = (char*) calloc(1, textLength + 1); + if (pMsgType->param.szReplyToApplicationID) { + memset(pMsgType->param.szReplyToApplicationID, 0, textLength + 1); + strncpy(pMsgType->param.szReplyToApplicationID, szTypeValue, textLength); + MSG_SEC_DEBUG("ReplyToApplication-ID:%s",pMsgType->param.szReplyToApplicationID); + } #endif } @@ -1579,7 +1583,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head case 0x0E: //Content-Location case 0x04: //Content-Location { - pLatinBuff = (char *)malloc(MMS_CONTENT_ID_LEN + 1); + pLatinBuff = (char *)calloc(1, MMS_CONTENT_ID_LEN + 1); if (pLatinBuff == NULL) goto __CATCH; @@ -1609,7 +1613,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head { char szContentID[MMS_CONTENT_ID_LEN + 1] = {0, }; - pLatinBuff = (char *)malloc(MMS_CONTENT_ID_LEN + 1); + pLatinBuff = (char *)calloc(1, MMS_CONTENT_ID_LEN + 1); if (pLatinBuff == NULL) goto __CATCH; @@ -1688,7 +1692,9 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head gCurMmsDecodeBuffPos--; valueLength++; - pLatinBuff = (char *)malloc(MSG_FILENAME_LEN_MAX); + pLatinBuff = (char *)calloc(1, MSG_FILENAME_LEN_MAX); + if (pLatinBuff == NULL) + goto __CATCH; memset(pLatinBuff, 0, MSG_FILENAME_LEN_MAX); textLength = __MmsBinaryDecodeText(pFile, pLatinBuff, MSG_FILENAME_LEN_MAX-1, totalLength); @@ -1774,7 +1780,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head case 0x30: //X-Wap-Content-URI skip this value MSG_DEBUG("X-Wap-Content-URI header."); - pLatinBuff = (char *)malloc(MMS_TEXT_LEN); + pLatinBuff = (char *)calloc(1, MMS_TEXT_LEN); if (pLatinBuff == NULL) goto __CATCH; @@ -1853,7 +1859,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head if (__MmsBinaryDecodeCheckAndDecreaseLength(&headerLen, length) == false) goto __RETURN; - szTemp = (char *)malloc(valueLength); + szTemp = (char *)calloc(1, valueLength); if (szTemp == NULL) goto __CATCH; @@ -1923,7 +1929,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head { char szContentID[MMS_CONTENT_ID_LEN + 1]; - pLatinBuff = (char *)malloc(MMS_CONTENT_ID_LEN + 1); + pLatinBuff = (char *)calloc(1, MMS_CONTENT_ID_LEN + 1); if (pLatinBuff == NULL) { goto __CATCH; @@ -1947,7 +1953,7 @@ static bool __MmsBinaryDecodePartHeader(FILE *pFile, MsgType *pMsgType, int head } case MMS_BODYHDR_CONTENTLOCATION: // Content-Location - pLatinBuff = (char *)malloc(MMS_CONTENT_ID_LEN + 1); + pLatinBuff = (char *)calloc(1, MMS_CONTENT_ID_LEN + 1); if (pLatinBuff == NULL) goto __CATCH; @@ -2262,7 +2268,7 @@ static bool __MmsBinaryDecodeEachPart(FILE *pFile, char *szFilePath, MsgType *pM /* Content Type */ if (szFilePath != NULL) - strncpy(pMsgType->szOrgFilePath, szFilePath, strlen(szFilePath)); + snprintf(pMsgType->szOrgFilePath, sizeof(pMsgType->szOrgFilePath), "%s", szFilePath); pMsgType->offset = __MmsGetDecodeOffset(); pMsgType->size = headerLength; @@ -2296,7 +2302,7 @@ static bool __MmsBinaryDecodeEachPart(FILE *pFile, char *szFilePath, MsgType *pM /* Part Body */ if (szFilePath != NULL) - strncpy(pMsgBody->szOrgFilePath, szFilePath, strlen(szFilePath)); + snprintf(pMsgBody->szOrgFilePath, sizeof(pMsgBody->szOrgFilePath), "%s", szFilePath); pMsgBody->offset = __MmsGetDecodeOffset(); pMsgBody->size = bodyLength; @@ -2559,7 +2565,7 @@ static UINT32 __MmsHeaderDecodeIntegerByLength(FILE *pFile, UINT32 length, int t if (length == 0) return 0; - pData = (char *)malloc(length + 1); + pData = (char *)calloc(1, length + 1); if (pData == NULL) { MSG_DEBUG("pData alloc fail"); goto __CATCH; @@ -2623,9 +2629,9 @@ static bool __MmsBinaryDecodeInteger(FILE *pFile, UINT32 *pInteger, int *pIntLen if (oneByte < 0x1F) /* long integer : WAP-230-WSP-20010118-p, Proposed Version 18 January 2001 (pp.86) */ { - pData = (char *)malloc(oneByte + 1); + pData = (char *)calloc(1, oneByte + 1); if (pData == NULL) { - MSG_DEBUG("pData memalloc fail"); + MSG_DEBUG("pData calloc fail"); goto __CATCH; } memset(pData, 0, oneByte + 1); @@ -2848,7 +2854,7 @@ static int __MmsBinaryDecodeQuotedString(FILE *pFile, char *szBuff, int bufLen, goto __CATCH; } - pData = (char *)malloc(gMmsDecodeBufLen + 1); + pData = (char *)calloc(1, gMmsDecodeBufLen + 1); if (pData == NULL) goto __CATCH; @@ -2886,7 +2892,7 @@ static int __MmsBinaryDecodeQuotedString(FILE *pFile, char *szBuff, int bufLen, } /* while */ if (length > 0) { - pData = (char *)malloc(length); + pData = (char *)calloc(1, length); if (pData == NULL) goto __CATCH; @@ -2990,7 +2996,7 @@ static int __MmsBinaryDecodeText(FILE *pFile, char *szBuff, int bufLen, int tota goto __CATCH; } - pData = (char *)malloc(gMmsDecodeBufLen + 1); + pData = (char *)calloc(1, gMmsDecodeBufLen + 1); if (pData == NULL) goto __CATCH; @@ -3029,7 +3035,7 @@ static int __MmsBinaryDecodeText(FILE *pFile, char *szBuff, int bufLen, int tota } /* while */ if (length > 0) { - pData = (char *)malloc(length); + pData = (char *)calloc(1, length); if (pData == NULL) goto __CATCH; @@ -3136,7 +3142,7 @@ static char* __MmsBinaryDecodeText2(FILE *pFile, int totalLength, int *pLength) goto __CATCH; } - pData = (char *)malloc(gMmsDecodeBufLen + 1); + pData = (char *)calloc(1, gMmsDecodeBufLen + 1); if (pData == NULL) goto __CATCH; @@ -3146,7 +3152,7 @@ static char* __MmsBinaryDecodeText2(FILE *pFile, int totalLength, int *pLength) goto __CATCH; if (szBuff == NULL) { - szBuff = (char *)malloc(gMmsDecodeBufLen + 1); + szBuff = (char *)calloc(1, gMmsDecodeBufLen + 1); } else { szTempPtr = (char *)realloc(szBuff, curLen + gMmsDecodeBufLen + 1); @@ -3197,7 +3203,7 @@ static char* __MmsBinaryDecodeText2(FILE *pFile, int totalLength, int *pLength) } /* while */ if (length > 0) { - pData = (char *)malloc(length); + pData = (char *)calloc(1, length); if (pData == NULL) { goto __CATCH; } @@ -3207,7 +3213,7 @@ static char* __MmsBinaryDecodeText2(FILE *pFile, int totalLength, int *pLength) } if (szBuff == NULL) { - szBuff = (char *)malloc(length); + szBuff = (char *)calloc(1, length); } else { szTempPtr = (char *)realloc(szBuff, curLen + length); @@ -3374,7 +3380,7 @@ static bool __MmsBinaryDecodeEncodedString(FILE *pFile, char *szBuff, int bufLen if (nTemp < 0) { /* There can be some error in data - no NULL -> try again with value length */ - pData = (char *)malloc(valueLength - charSetLen); + pData = (char *)calloc(1, valueLength - charSetLen); if (pData == NULL) { MSG_DEBUG("pData alloc fail."); goto __CATCH; @@ -3502,7 +3508,7 @@ MsgHeaderAddress *__MmsDecodeEncodedAddress(FILE *pFile, int totalLength) if (pAddrStr == NULL) { /* There can be some error in data - no NULL -> try again with value length */ - pAddrStr = (char *)malloc(valueLength - charSetLen); + pAddrStr = (char *)calloc(1, valueLength - charSetLen); if (pAddrStr == NULL) { MSG_DEBUG("pData alloc fail."); goto __CATCH; @@ -3519,7 +3525,7 @@ MsgHeaderAddress *__MmsDecodeEncodedAddress(FILE *pFile, int totalLength) break; } - pAddr = (MsgHeaderAddress *)malloc(sizeof(MsgHeaderAddress)); + pAddr = (MsgHeaderAddress *)calloc(1, sizeof(MsgHeaderAddress)); if (pAddr == NULL) goto __CATCH; @@ -3624,7 +3630,7 @@ static int __MmsDecodeGetFilename(FILE *pFile, char *szBuff, int bufLen, int tot if (utf8BufSize < 3) utf8BufSize = 3;//min value - pUTF8Buff = (char *)malloc(utf8BufSize + 1); + pUTF8Buff = (char *)calloc(1, utf8BufSize + 1); if (pUTF8Buff == NULL) { MSG_DEBUG("pUTF8Buff alloc fail"); goto __CATCH; @@ -3790,7 +3796,7 @@ bool MmsReadMsgBody(msg_message_id_t msgID, bool bSavePartsAsTempFiles, bool bRe if(MsgFseek(pFile, pMsg->msgBody.pPresentationBody->offset, SEEK_SET) < 0) goto __CATCH; - pMsg->msgBody.pPresentationBody->body.pText = (char *)malloc(pMsg->msgBody.pPresentationBody->size + 1); + pMsg->msgBody.pPresentationBody->body.pText = (char *)calloc(1, pMsg->msgBody.pPresentationBody->size + 1); if (pMsg->msgBody.pPresentationBody->body.pText == NULL) goto __CATCH; @@ -3976,8 +3982,8 @@ static char *__MsgGetStringUntilDelimiter(char *pszString, char delimiter) bufLength = pszStrDelimiter - pszString; - if ((pszBuffer = (char*)malloc (bufLength + 1)) == NULL) { - MSG_DEBUG("malloc is failed"); + if ((pszBuffer = (char*)calloc (1, bufLength + 1)) == NULL) { + MSG_DEBUG("calloc is failed"); return NULL; } memset(pszBuffer, 0, bufLength + 1) ; @@ -4001,7 +4007,7 @@ char *MsgChangeHexString(char *pOrg) cLen = strlen(pOrg); - pNew = (char *)malloc(cLen + 1); + pNew = (char *)calloc(1, cLen + 1); if (pNew == NULL) return NULL; @@ -4086,158 +4092,158 @@ static bool __MsgParseParameter(MsgType *pType, char *pSrc) pDec = MsgDecodeText(pName); } - switch (MmsGetTextType(MmsCodeParameterCode, pSrc)) { - case MSG_PARAM_BOUNDARY: + if (pDec) { + switch (MmsGetTextType(MmsCodeParameterCode, pSrc)) { + case MSG_PARAM_BOUNDARY: - /* RFC 822: boundary := 0*69<bchars> bcharsnospace */ + /* RFC 822: boundary := 0*69<bchars> bcharsnospace */ - memset (pType->param.szBoundary, 0, MSG_BOUNDARY_LEN + 1); - strncpy(pType->param.szBoundary, pDec, MSG_BOUNDARY_LEN); - MSG_SEC_INFO("szBoundary = [%s]", pType->param.szBoundary); - break; + memset (pType->param.szBoundary, 0, MSG_BOUNDARY_LEN + 1); + strncpy(pType->param.szBoundary, pDec, MSG_BOUNDARY_LEN); + MSG_SEC_INFO("szBoundary = [%s]", pType->param.szBoundary); + break; - case MSG_PARAM_CHARSET: - pType->param.charset = MmsGetTextType(MmsCodeParameterCode, pDec); + case MSG_PARAM_CHARSET: + pType->param.charset = MmsGetTextType(MmsCodeParameterCode, pDec); - if (pType->param.charset == -1) - pType->param.charset = MSG_CHARSET_UNKNOWN; + if (pType->param.charset == -1) + pType->param.charset = MSG_CHARSET_UNKNOWN; - MSG_SEC_INFO("type = %d [charset] = %d", pType->type, pType->param.charset); - break; + MSG_SEC_INFO("type = %d [charset] = %d", pType->type, pType->param.charset); + break; + + case MSG_PARAM_NAME: - case MSG_PARAM_NAME: + memset (pType->param.szName, 0, MSG_LOCALE_FILENAME_LEN_MAX + 1); - memset (pType->param.szName, 0, MSG_LOCALE_FILENAME_LEN_MAX + 1); + pUTF8Buff = __MsgConvertLatin2UTF8FileName(pDec); - pUTF8Buff = __MsgConvertLatin2UTF8FileName(pDec); + if (pUTF8Buff) { + if ((pExt = strrchr(pUTF8Buff, '.')) != NULL) { + if ((MSG_LOCALE_FILENAME_LEN_MAX-1) < strlen(pUTF8Buff)) { + nameLen = (MSG_LOCALE_FILENAME_LEN_MAX-1) - strlen(pExt); + } else { + nameLen = strlen(pUTF8Buff) - strlen(pExt); + } - if (pUTF8Buff) { - if ((pExt = strrchr(pUTF8Buff, '.')) != NULL) { - if ((MSG_LOCALE_FILENAME_LEN_MAX-1) < strlen(pUTF8Buff)) { - nameLen = (MSG_LOCALE_FILENAME_LEN_MAX-1) - strlen(pExt); + strncpy(pType->param.szName, pUTF8Buff, nameLen); + g_strlcat(pType->param.szName, pExt, sizeof(pType->param.szName)); } else { - nameLen = strlen(pUTF8Buff) - strlen(pExt); + strncpy(pType->param.szName, pUTF8Buff, (MSG_LOCALE_FILENAME_LEN_MAX-1)); } + free(pUTF8Buff); + pUTF8Buff = NULL; - strncpy(pType->param.szName, pUTF8Buff, nameLen); - g_strlcat(pType->param.szName, pExt, sizeof(pType->param.szName)); - } else { - strncpy(pType->param.szName, pUTF8Buff, (MSG_LOCALE_FILENAME_LEN_MAX-1)); - } - free(pUTF8Buff); - pUTF8Buff = NULL; + if (__MsgChangeSpace(pType->param.szName, &szSrc) == true) { + if (szSrc) + strncpy(pType->param.szName, szSrc , strlen(szSrc)); + } - if (__MsgChangeSpace(pType->param.szName, &szSrc) == true) { - if (szSrc) - strncpy(pType->param.szName, szSrc , strlen(szSrc)); - } + if (szSrc) { + free(szSrc); + szSrc = NULL; + } - if (szSrc) { - free(szSrc); - szSrc = NULL; + // Remvoe '/', ex) Content-Type: image/gif; name="images/vf7.gif" + __MsgRemoveFilePath(pType->param.szName); + } else { + MSG_SEC_DEBUG("MsgConvertLatin2UTF8FileName(%s) return NULL", pDec); } - // Remvoe '/', ex) Content-Type: image/gif; name="images/vf7.gif" - __MsgRemoveFilePath(pType->param.szName); - } else { - MSG_SEC_DEBUG("MsgConvertLatin2UTF8FileName(%s) return NULL", pDec); - } + MSG_SEC_INFO("szName = %s", pType->param.szName); + break; - MSG_SEC_INFO("szName = %s", pType->param.szName); - break; + case MSG_PARAM_FILENAME: - case MSG_PARAM_FILENAME: + memset (pType->param.szFileName, 0, MSG_FILENAME_LEN_MAX+1); - memset (pType->param.szFileName, 0, MSG_FILENAME_LEN_MAX+1); + pUTF8Buff = __MsgConvertLatin2UTF8FileName(pDec); - pUTF8Buff = __MsgConvertLatin2UTF8FileName(pDec); + if (pUTF8Buff) { + if ((pExt = strrchr(pUTF8Buff, '.')) != NULL) { + if ((MSG_FILENAME_LEN_MAX-1) < strlen(pUTF8Buff)) { + nameLen = (MSG_FILENAME_LEN_MAX-1) - strlen(pExt); + } else { + nameLen = strlen(pUTF8Buff) - strlen(pExt); + } - if (pUTF8Buff) { - if ((pExt = strrchr(pUTF8Buff, '.')) != NULL) { - if ((MSG_FILENAME_LEN_MAX-1) < strlen(pUTF8Buff)) { - nameLen = (MSG_FILENAME_LEN_MAX-1) - strlen(pExt); + strncpy(pType->param.szFileName, pUTF8Buff, nameLen); + g_strlcat (pType->param.szFileName, pExt, sizeof(pType->param.szFileName)); } else { - nameLen = strlen(pUTF8Buff) - strlen(pExt); + strncpy(pType->param.szFileName, pUTF8Buff, (MSG_FILENAME_LEN_MAX-1)); } + free(pUTF8Buff); + pUTF8Buff = NULL; - strncpy(pType->param.szFileName, pUTF8Buff, nameLen); - g_strlcat (pType->param.szFileName, pExt, sizeof(pType->param.szFileName)); - } else { - strncpy(pType->param.szFileName, pUTF8Buff, (MSG_FILENAME_LEN_MAX-1)); - } - free(pUTF8Buff); - pUTF8Buff = NULL; + if (__MsgChangeSpace(pType->param.szFileName, &szSrc) == true) { + snprintf(pType->param.szFileName, sizeof(pType->param.szFileName), "%s", szSrc); + } - if (__MsgChangeSpace(pType->param.szFileName, &szSrc) == true) { - snprintf(pType->param.szFileName, sizeof(pType->param.szFileName), "%s", szSrc); - } + if (szSrc) { + free(szSrc); + szSrc = NULL; + } - if (szSrc) { - free(szSrc); - szSrc = NULL; + // Remvoe '/', ex) Content-Type: image/gif; name="images/vf7.gif" + __MsgRemoveFilePath(pType->param.szFileName); + } else { + MSG_SEC_DEBUG("MsgConvertLatin2UTF8FileName(%s) return NULL", pDec); } - // Remvoe '/', ex) Content-Type: image/gif; name="images/vf7.gif" - __MsgRemoveFilePath(pType->param.szFileName); - } else { - MSG_SEC_DEBUG("MsgConvertLatin2UTF8FileName(%s) return NULL", pDec); - } - - MSG_SEC_INFO("szFileName = %s", pType->param.szFileName); + MSG_SEC_INFO("szFileName = %s", pType->param.szFileName); - break; + break; - case MSG_PARAM_TYPE: + case MSG_PARAM_TYPE: - /* type/subtype of root. Only if content-type is multipart/related */ + /* type/subtype of root. Only if content-type is multipart/related */ - pType->param.type = MimeGetMimeIntFromMimeString(pDec); - MSG_SEC_INFO("type = %d", pType->param.type); + pType->param.type = MimeGetMimeIntFromMimeString(pDec); + MSG_SEC_INFO("type = %d", pType->param.type); - break; + break; - case MSG_PARAM_START: + case MSG_PARAM_START: - /* Content-id. Only if content-type is multipart/related */ + /* Content-id. Only if content-type is multipart/related */ - memset (pType->param.szStart, 0, MSG_MSG_ID_LEN + 1); - strncpy(pType->param.szStart, pDec, MSG_MSG_ID_LEN); + memset (pType->param.szStart, 0, MSG_MSG_ID_LEN + 1); + strncpy(pType->param.szStart, pDec, MSG_MSG_ID_LEN); - MSG_SEC_INFO("szStart = %s", pType->param.szStart); + MSG_SEC_INFO("szStart = %s", pType->param.szStart); - break; + break; - case MSG_PARAM_START_INFO : + case MSG_PARAM_START_INFO : - /* Only if content-type is multipart/related */ + /* Only if content-type is multipart/related */ - memset (pType->param.szStartInfo, 0, MSG_MSG_ID_LEN + 1); - strncpy(pType->param.szStartInfo, pDec, MSG_MSG_ID_LEN); + memset (pType->param.szStartInfo, 0, MSG_MSG_ID_LEN + 1); + strncpy(pType->param.szStartInfo, pDec, MSG_MSG_ID_LEN); - MSG_SEC_INFO("szStartInfo = %s", pType->param.szStartInfo); + MSG_SEC_INFO("szStartInfo = %s", pType->param.szStartInfo); - break; + break; - case MSG_PARAM_REPORT_TYPE : + case MSG_PARAM_REPORT_TYPE : - // only used as parameter of Content-Type: multipart/report; report-type=delivery-status; + // only used as parameter of Content-Type: multipart/report; report-type=delivery-status; - if (pDec != NULL && strcasecmp(pDec, "delivery-status") == 0) { - pType->param.reportType = MSG_PARAM_REPORT_TYPE_DELIVERY_STATUS; - } else { - pType->param.reportType = MSG_PARAM_REPORT_TYPE_UNKNOWN; - } + if (pDec != NULL && strcasecmp(pDec, "delivery-status") == 0) { + pType->param.reportType = MSG_PARAM_REPORT_TYPE_DELIVERY_STATUS; + } else { + pType->param.reportType = MSG_PARAM_REPORT_TYPE_UNKNOWN; + } - MSG_SEC_INFO("reportType = %s", pDec); - break; + MSG_SEC_INFO("reportType = %s", pDec); + break; - default: + default: - MSG_DEBUG("Unknown paremeter (%s)", pDec); - break; - } + MSG_DEBUG("Unknown paremeter (%s)", pDec); + break; + } - if (pDec) { free(pDec); pDec = NULL; } @@ -4321,7 +4327,7 @@ static char *__MsgConvertLatin2UTF8FileName(char *pSrc) if (utf8BufSize < 3) utf8BufSize = 3; //min value - pUTF8Buff = (char *)malloc(utf8BufSize + 1); + pUTF8Buff = (char *)calloc(1, utf8BufSize + 1); if (pUTF8Buff == NULL) { MSG_DEBUG("pUTF8Buff alloc fail"); @@ -4377,7 +4383,7 @@ static bool __MsgChangeSpace(char *pOrg, char **ppNew) cLen = strlen(pOrg); - pNew = (char *)malloc(cLen + 1); + pNew = (char *)calloc(1, cLen + 1); if (pNew == NULL) return false; @@ -4401,29 +4407,16 @@ static bool __MsgChangeSpace(char *pOrg, char **ppNew) static void __MsgRemoveFilePath(char *pSrc) { // Remvoe '/', ex) Content-Type: image/gif; name="images/vf7.gif" - char *pPath = NULL; char *pTemp = NULL; - char szFileName[MSG_FILENAME_LEN_MAX] = {0}; - - if (pSrc == NULL) - return; + char *tmp_name = NULL; - pTemp = pSrc; - while ((pTemp = strchr(pTemp, '/')) != NULL) { - // Find the last '/' - pPath = pTemp; - pTemp++; + tmp_name = MsgGetFileName(pSrc); + if (tmp_name) { + snprintf(pSrc, strlen(tmp_name), "%s", tmp_name); + g_free(tmp_name); + tmp_name = NULL; } - if (pPath) { - MSG_SEC_DEBUG("filename(%s)", pSrc); - - // case : images/vf7.gif -> vf7.gif - if (pPath != NULL && *(pPath+1) != '\0') { - strncpy(szFileName, pPath+1, strlen(pPath+1)); - strncpy(pSrc, szFileName , strlen(szFileName)); - } - } // Remove additional file information // ex) Content-type: application/octet-stream; name="060728gibson_210.jpg?size=s" // if "?size=" exist, insert NULL char. @@ -4952,7 +4945,7 @@ char *MsgResolveContentURI(char *szSrc) length = strlen(szSrc) + 1; } - szTemp = (char *)malloc(length); + szTemp = (char *)calloc(1, length); if (szTemp == NULL) { MSG_DEBUG("memory full"); goto __CATCH; @@ -4988,7 +4981,7 @@ char *MsgRemoveQuoteFromFilename(char *pSrc) cLen = strlen(pSrc); - pBuff = (char *)malloc(cLen + 1); + pBuff = (char *)calloc(1, cLen + 1); if (pBuff == NULL) { MSG_DEBUG("pBuff mem alloc fail!"); @@ -5869,7 +5862,7 @@ char *__MmsGetBinaryUTF8Data(char *pData, int nRead, int msgEncodingValue, int m *npRead = nTemp; } - pReturnData = (char *)malloc(*npRead); + pReturnData = (char *)calloc(1, *npRead); if (pReturnData == NULL) { MSG_DEBUG("pReturnData alloc fail."); goto __CATCH; @@ -6152,7 +6145,7 @@ void MmsPluginDecoder::decodeMmsPdu(MmsMsg *pMsg, msg_message_id_t msgID, const if(MsgFseek(pFile, pMsg->msgBody.pPresentationBody->offset, SEEK_SET) < 0) goto __CATCH; - pMsg->msgBody.pPresentationBody->body.pText = (char *)malloc(pMsg->msgBody.pPresentationBody->size + 1); + pMsg->msgBody.pPresentationBody->body.pText = (char *)calloc(1, pMsg->msgBody.pPresentationBody->size + 1); if (pMsg->msgBody.pPresentationBody->body.pText == NULL) goto __CATCH; diff --git a/plugin/mms_plugin/MmsPluginEncode.cpp b/plugin/mms_plugin/MmsPluginEncode.cpp index 88676ac..abf59b1 100755 --- a/plugin/mms_plugin/MmsPluginEncode.cpp +++ b/plugin/mms_plugin/MmsPluginEncode.cpp @@ -19,7 +19,10 @@ #include <stdio.h> #include <errno.h> #include <sys/stat.h> + +#include "MsgCppTypes.h" #include "MsgUtilFile.h" + #include "MmsPluginDebug.h" #include "MmsPluginEncode.h" #include "MmsPluginCodecTypes.h" @@ -27,6 +30,7 @@ #include "MmsPluginMIME.h" #include "MmsPluginUtil.h" +using namespace std; /** Sending message related variables ------------------------ */ static char gszMmsEncodeBuf[MSG_MMS_ENCODE_BUFFER_MAX] = {0, }; @@ -505,13 +509,17 @@ bool MmsEncodeReadReport10(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t m char *pText = NULL; MsgMultipart *pPart = NULL; MsgType msgType; - MsgBody msgBody; + + MsgBody *msgBody = NULL; + unique_ptr<MsgBody*, void(*)(MsgBody**)> buf(&msgBody, unique_ptr_deleter); + msgBody = (MsgBody *)new char[sizeof(MsgBody)]; + memset(msgBody, 0x00, sizeof(MsgBody)); char *pszReportMsg = NULL; - int maxLen = 0; + int maxLen = 0; - struct tm *dateTime = NULL; - time_t RawTime = 0; + struct tm dateTime; + time_t RawTime = 0; MmsRegisterEncodeBuffer(gszMmsEncodeBuf, MSG_MMS_ENCODE_BUFFER_MAX); @@ -523,18 +531,17 @@ bool MmsEncodeReadReport10(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t m } memset(&msgType, 0, sizeof(MsgType)); - memset(&msgBody, 0, sizeof(MsgBody)); - pText = (char *)malloc(MSG_STDSTR_LONG); + pText = (char *)calloc(1, MSG_STDSTR_LONG); if (pText == NULL) { - MSG_DEBUG("text body malloc fail"); + MSG_DEBUG("text body calloc fail"); goto __CATCH; } memset(pText, 0, MSG_STDSTR_LONG); time(&RawTime); - dateTime = localtime(&RawTime); + localtime_r(&RawTime, &dateTime); // get report message if (mmsReadStatus == MSG_READ_REPORT_IS_DELETED) { @@ -550,7 +557,7 @@ bool MmsEncodeReadReport10(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t m snprintf (pText, MSG_STDSTR_LONG, "%s", pszReportMsg); } else { snprintf(pText, MSG_STDSTR_LONG, "%s\r\n\r\n%.4d/%.2d/%.2d %.2d:%.2d\r\n", - pszReportMsg, dateTime->tm_year+1900, dateTime->tm_mon+1, dateTime->tm_mday, dateTime->tm_hour, dateTime->tm_min); + pszReportMsg, dateTime.tm_year+1900, dateTime.tm_mon+1, dateTime.tm_mday, dateTime.tm_hour, dateTime.tm_min); } // make header @@ -577,9 +584,9 @@ bool MmsEncodeReadReport10(FILE *pFile, MmsMsg *pMsg, msg_read_report_status_t m pPart->pBody->size = strlen(pText); pPart->pBody->body.pText = pText; - msgBody.body.pMultipart = pPart; + msgBody->body.pMultipart = pPart; - if (__MmsBinaryEncodeMsgBody(pFile, &msgType, &msgBody, 1, false) == false) { + if (__MmsBinaryEncodeMsgBody(pFile, &msgType, msgBody, 1, false) == false) { MSG_DEBUG("MmsBinaryEncodeMsgBody fail"); goto __CATCH; } @@ -997,7 +1004,7 @@ static bool __MmsBinaryEncodeReadReport10Hdr(FILE *pFile, MmsMsg *pMsg, msg_read /* To = Encoded-string */ if (pMsg && (strchr(pMsg->mmsAttrib.szFrom, '/') == NULL)) { length = strlen(pMsg->mmsAttrib.szFrom); - szTo = (char *)malloc(length + 11); + szTo = (char *)calloc(1, length + 11); if (szTo == NULL) { MSG_DEBUG("szTo alloc fail"); goto __CATCH; @@ -1144,7 +1151,7 @@ static bool __MmsBinaryEncodeReadReport11Hdr(FILE *pFile, MmsMsg *pMsg, msg_read if (strchr(pMsg->mmsAttrib.szFrom, '/') == NULL) { int length = 0; length = strlen(pMsg->mmsAttrib.szFrom); - szTo = (char *)malloc(length + 11); + szTo = (char *)calloc(1, length + 11); if (szTo == NULL) { MSG_DEBUG("szTo alloc fail"); @@ -1608,7 +1615,6 @@ static bool __MmsBinaryEncodeContentType(FILE *pFile, MsgType *pType, int typeLe if (MsgEncode2Base64(pszName, strlen(pszName), &tmpLength, tmpFileName) == true) { g_free(pszName); pszName = g_strdup_printf("=?UTF-8?B?%s?=", tmpFileName); - length = __MmsBinaryEncodeTextStringLen((UINT8*)pszName); MSG_DEBUG("base64 encode filename=[%s]", pszName); } } @@ -1823,7 +1829,7 @@ static bool __MmsBinaryEncodeMsgPart(FILE *pFile, int contentType, MsgType *pTyp pFile2 = MsgOpenFile(pType->szOrgFilePath, "rb"); if (pFile != NULL) { - pData = (char *)malloc(pType->size); + pData = (char *)calloc(1, pType->size); if (pData == NULL) goto __CATCH; @@ -2794,13 +2800,14 @@ static bool __MmsBinaryEncodeTrID(FILE *pFile, char *szTrID, int bufLen) int length = 0; UINT8 fieldCode = 0xff; char szBuff[MMS_TR_ID_LEN + 1] = {0, }; - struct tm *dateTime = NULL; - time_t RawTime = 0; - time_t dateSec = 0; + struct tm dateTime; + time_t RawTime = 0; + time_t dateSec = 0; time(&RawTime); - dateTime = localtime(&RawTime); - dateSec = mktime(dateTime); + localtime_r(&RawTime, &dateTime); + + dateSec = mktime(&dateTime); fieldCode = MmsGetBinaryValue(MmsCodeFieldCode, MMS_CODE_TRID) | 0x80; if (fieldCode == 0xff) { @@ -2929,18 +2936,18 @@ __CATCH: static bool __MmsBinaryEncodeDate(FILE *pFile, time_t inpDateSec) { - struct tm *dateTime = NULL; - time_t dateSec = 0; + struct tm dateTime; + time_t dateSec = 0; - if(inpDateSec > 0) + if (inpDateSec > 0) dateSec = inpDateSec; else dateSec = time(NULL); - dateTime = localtime(&dateSec); + localtime_r(&dateSec, &dateTime); - MSG_SEC_INFO("%d - %d - %d, %d : %d (SYSTEM)", dateTime->tm_year + 1900, dateTime->tm_mon + 1, dateTime->tm_mday - , dateTime->tm_hour, dateTime->tm_min); + MSG_SEC_INFO("%d - %d - %d, %d : %d (SYSTEM)", dateTime.tm_year + 1900, dateTime.tm_mon + 1, dateTime.tm_mday + , dateTime.tm_hour, dateTime.tm_min); if (dateSec > 0) { int length = 0; @@ -3192,17 +3199,17 @@ static bool __EncodeMmsMessage(MmsMsg *pMmsMsg, const char *raw_filepath) FILE *pFile = MsgOpenFile(raw_filepath, "wb+"); if (pFile == NULL) { - MSG_FATAL("File Open Error: %s", strerror(errno)); + MSG_FATAL("File Open Error: %s", g_strerror(errno)); goto __CATCH; } if (MsgFseek(pFile, 0L, SEEK_CUR) < 0) { - MSG_DEBUG("File Fseek Error: %s", strerror(errno)); + MSG_DEBUG("File Fseek Error: %s", g_strerror(errno)); goto __CATCH; } if (fchmod(fileno(pFile), file_mode) < 0) { - MSG_DEBUG("File chmod Error: %s", strerror(errno)); + MSG_DEBUG("File chmod Error: %s", g_strerror(errno)); goto __CATCH; } @@ -3252,12 +3259,14 @@ void MmsPluginEncoder::encodeMmsPdu(MMS_DATA_S *pMmsData, msg_message_id_t msgID { MmsMsg *pMmsMsg = (MmsMsg *)calloc(1, sizeof(MmsMsg)); - if (MmsConvertMmsMsg(pMmsMsg, pMmsData) != true) { - MSG_DEBUG("Fail to Compose MMS Message"); - goto __CATCH; - } + if (pMmsMsg) { + if (MmsConvertMmsMsg(pMmsMsg, pMmsData) != true) { + MSG_DEBUG("Fail to Compose MMS Message"); + goto __CATCH; + } - encodeMmsPdu(pMmsMsg, msgID, pduFilePath); + encodeMmsPdu(pMmsMsg, msgID, pduFilePath); + } __CATCH: MmsReleaseMmsMsg(pMmsMsg); diff --git a/plugin/mms_plugin/MmsPluginHttp.cpp b/plugin/mms_plugin/MmsPluginHttp.cpp index b2a7dab..083880d 100755 --- a/plugin/mms_plugin/MmsPluginHttp.cpp +++ b/plugin/mms_plugin/MmsPluginHttp.cpp @@ -255,6 +255,7 @@ static bool __httpGetHeaderField(MMS_HTTP_HEADER_FIELD_T httpHeaderItem, char *s case MMS_HH_USER_AGENT: { +#if 0 char szUserAgent[1024 + 1]; char *uagent = NULL; @@ -274,6 +275,9 @@ static bool __httpGetHeaderField(MMS_HTTP_HEADER_FIELD_T httpHeaderItem, char *s free(uagent); uagent = NULL; } +#else + snprintf((char *)szHeaderBuffer, 1024, "%s", MSG_MMS_HH_USER_AGENT); +#endif result = true; } break; @@ -726,7 +730,7 @@ MMS_HTTP_ERROR_E MmsPluginHttpAgent::httpRequest(http_request_info_s &request_in fclose(respfile); respfile = NULL; - if (g_file_get_contents(conf_filename, &request_info.response_data, (gsize*)&request_info.response_data_len, NULL) == false) { + if (g_file_get_contents(conf_filename, &request_info.response_data, &request_info.response_data_len, NULL) == false) { MSG_WARN("Fail to g_file_get_contents"); } } diff --git a/plugin/mms_plugin/MmsPluginInternal.cpp b/plugin/mms_plugin/MmsPluginInternal.cpp index 2040e64..4343686 100755 --- a/plugin/mms_plugin/MmsPluginInternal.cpp +++ b/plugin/mms_plugin/MmsPluginInternal.cpp @@ -18,6 +18,7 @@ #include <errno.h> #include <sys/stat.h> +#include "MsgCppTypes.h" #include "MsgUtilFile.h" #include "MsgException.h" #include "MsgSettingTypes.h" @@ -26,6 +27,7 @@ #include "MsgStorageHandler.h" #include "MsgSerialize.h" #include "MsgSpamFilter.h" + #include "MmsPluginDebug.h" #include "MmsPluginTypes.h" #include "MmsPluginCodec.h" @@ -97,7 +99,8 @@ void MmsPluginInternal::processReceivedInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQ MsgCloseFile(pFile); - remove(pMsgInfo->msgData); + if (remove(pMsgInfo->msgData) != 0) + MSG_DEBUG("Fail remove"); switch (mmsHeader.type) { case MMS_MSGTYPE_NOTIFICATION_IND: @@ -161,9 +164,15 @@ bool MmsPluginInternal::processNotiInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST } MMS_DATA_S *mms_data = MsgMmsCreate(); + if (mms_data == NULL) return false; { mms_data->header = MsgMmsCreateHeader(); + if (mms_data->header == NULL) { + MsgMmsRelease(&mms_data); + return false; + } + MMS_HEADER_DATA_S *pHeader = mms_data->header; pHeader->messageType = mmsHeader.type; @@ -181,7 +190,7 @@ bool MmsPluginInternal::processNotiInd(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_REQUEST //Subject snprintf(pHeader->szSubject, sizeof(pHeader->szSubject), "%s", mmsHeader.szSubject); //Delivery Report - pHeader->bDeliveryReport = mmsHeader.deliveryReport; + pHeader->bDeliveryReport = (mmsHeader.deliveryReport != MMS_REPORT_YES); //Message Class pHeader->messageClass = mmsHeader.msgClass; @@ -607,17 +616,11 @@ void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTra snprintf(fullPath, MAX_FULL_PATH_SIZE+1, "%s%s", MSG_IPC_DATA_PATH, filename); - int ret = rename(pRetrievedFilePath, fullPath); - if (ret != 0) { - MSG_DEBUG("File rename Error: %s", strerror(errno)); - } - - if (MsgChmod(fullPath, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) == false) { - MSG_DEBUG("File Write Error: %s", strerror(errno)); - } - - if (MsgChown(fullPath, 0, 6502 ) == false) { - MSG_DEBUG("File Write Error: %s", strerror(errno)); + if (pRetrievedFilePath) { + int ret = rename(pRetrievedFilePath, fullPath); + if (ret != 0) { + MSG_DEBUG("File rename Error: %s", g_strerror(errno)); + } } } #endif @@ -639,6 +642,11 @@ void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTra MmsPluginStorage::instance()->getMmsMessage(&pMmsMsg); MMS_DATA_S *pMmsData = MsgMmsCreate(); + if (pMmsData == NULL) { + MSG_SEC_DEBUG("Fail to create mms"); + goto __CATCH; + } + pMmsData->header = MsgMmsCreateHeader(); MmsConvertMmsData(pMmsMsg, pMmsData); @@ -666,9 +674,11 @@ void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTra } {//make Preview info for APP - MmsPluginAppBase appBase(pMmsData); - appBase.makePreviewInfo(pMsgInfo->msgId, false, pRetrievedFilePath); - appBase.getFirstPageTextFilePath(pMsgInfo->msgText, sizeof(pMsgInfo->msgText)); + MmsPluginAppBase *appBase; + appBase = new MmsPluginAppBase(pMmsData); + appBase->makePreviewInfo(pMsgInfo->msgId, false, pRetrievedFilePath); + appBase->getFirstPageTextFilePath(pMsgInfo->msgText, sizeof(pMsgInfo->msgText)); + delete appBase; } MsgMmsRelease(&pMmsData); @@ -959,7 +969,6 @@ bool MmsPluginInternal::checkFilterMmsBody(MMS_DATA_S *pMmsData) return false; bool bFiltered = false; - MMS_MESSAGE_DATA_S mmsMsg; MMS_PAGE_S *pPage = NULL; MMS_MEDIA_S *pMedia = NULL; char filePath[MSG_FILEPATH_LEN_MAX + 1]; @@ -967,21 +976,25 @@ bool MmsPluginInternal::checkFilterMmsBody(MMS_DATA_S *pMmsData) MsgDbHandler *dbHandle = getDbHandle(); MimeType mimeType = MIME_UNKNOWN; - memset(&mmsMsg, 0x00, sizeof(MMS_MESSAGE_DATA_S)); - MsgMmsConvertMmsDataToMmsMessageData(pMmsData, &mmsMsg); + MMS_MESSAGE_DATA_S *mmsMsg = NULL; + unique_ptr<MMS_MESSAGE_DATA_S*, void(*)(MMS_MESSAGE_DATA_S**)> buf(&mmsMsg, unique_ptr_deleter); + mmsMsg = (MMS_MESSAGE_DATA_S *)new char[sizeof(MMS_MESSAGE_DATA_S)]; + memset(mmsMsg, 0x00, sizeof(MMS_MESSAGE_DATA_S)); + + MsgMmsConvertMmsDataToMmsMessageData(pMmsData, mmsMsg); // Get the text data from the 1st slide. - if (mmsMsg.pageCnt <= 0) { - MSG_WARN("pageCnt : %d", mmsMsg.pageCnt); - MsgMmsReleaseMmsLists(&mmsMsg); + if (mmsMsg->pageCnt <= 0) { + MSG_WARN("pageCnt : %d", mmsMsg->pageCnt); + MsgMmsReleaseMmsLists(mmsMsg); return false; } - pPage = _MsgMmsGetPage(&mmsMsg, 0); + pPage = _MsgMmsGetPage(mmsMsg, 0); if (!pPage) { MSG_WARN("page is NULL"); - MsgMmsReleaseMmsLists(&mmsMsg); + MsgMmsReleaseMmsLists(mmsMsg); return false; } @@ -1010,7 +1023,7 @@ bool MmsPluginInternal::checkFilterMmsBody(MMS_DATA_S *pMmsData) } } - MsgMmsReleaseMmsLists(&mmsMsg); + MsgMmsReleaseMmsLists(mmsMsg); return bFiltered; } diff --git a/plugin/mms_plugin/MmsPluginMessage.cpp b/plugin/mms_plugin/MmsPluginMessage.cpp index 120529b..b774281 100755 --- a/plugin/mms_plugin/MmsPluginMessage.cpp +++ b/plugin/mms_plugin/MmsPluginMessage.cpp @@ -137,7 +137,7 @@ char *MmsComposeAddress(const MSG_MESSAGE_INFO_S *pMsgInfo, int recipientType) // Address String copy for (int i = 0; i < nAddressCnt; ++i) { if (pMsgInfo->addressList[i].recipientType == recipientType) { - if (strlen(szCompose) > 0) + if (szCompose && strlen(szCompose) > 0) g_strlcat(szCompose, MSG_STR_ADDR_DELIMETER, addrLen + 1); memset(pString, 0x00, (MSG_LOCALE_NAME_LEN + MSG_ADDR_LEN + 3) * sizeof(char)); @@ -220,7 +220,7 @@ MsgMultipart *MmsMakeMultipart(MimeType mimeType, char *szTitleName, char *szOrg MsgMultipart *pMultipart = NULL; if ((pMultipart = MmsAllocMultipart()) == NULL) - goto __CATCH; + return NULL; pMultipart->type.type = mimeType; @@ -255,17 +255,13 @@ MsgMultipart *MmsMakeMultipart(MimeType mimeType, char *szTitleName, char *szOrg pMultipart->pBody->size = MsgGetFileSize(szOrgFilePath); } return pMultipart; - -__CATCH: - - return NULL; } void MmsComposeNotiMessage(MmsMsg *pMmsMsg, msg_message_id_t msgID) { MSG_BEGIN(); - struct tm *timeInfo = NULL; + struct tm timeInfo; time_t RawTime = 0; time_t nTimeInSecs = 0; @@ -279,12 +275,13 @@ void MmsComposeNotiMessage(MmsMsg *pMmsMsg, msg_message_id_t msgID) // setting date time(&RawTime); - timeInfo = localtime(&RawTime); - nTimeInSecs = mktime(timeInfo); + localtime_r(&RawTime, &timeInfo); + nTimeInSecs = mktime(&timeInfo); + pMmsMsg->mmsAttrib.date = nTimeInSecs; - pMmsMsg->mmsAttrib.bReportAllowed = mmsHeader.reportAllowed; - pMmsMsg->mmsAttrib.bAskDeliveryReport = mmsHeader.deliveryReport; + pMmsMsg->mmsAttrib.bReportAllowed = (mmsHeader.reportAllowed != MMS_REPORTALLOWED_YES); + pMmsMsg->mmsAttrib.bAskDeliveryReport = (mmsHeader.deliveryReport != MMS_REPORT_YES); MSG_DEBUG("######## Version = %d ########", pMmsMsg->mmsAttrib.version); @@ -320,7 +317,7 @@ void MmsComposeNotiMessage(MmsMsg *pMmsMsg, msg_message_id_t msgID) void MmsComposeReadReportMessage(MmsMsg *pMmsMsg, const MSG_MESSAGE_INFO_S *pMsgInfo, msg_message_id_t selectedMsgId) { - struct tm *timeInfo = NULL; + struct tm timeInfo; time_t RawTime = 0; time_t nTimeInSecs = 0; @@ -340,8 +337,8 @@ void MmsComposeReadReportMessage(MmsMsg *pMmsMsg, const MSG_MESSAGE_INFO_S *pMsg // setting date time(&RawTime); - timeInfo = localtime(&RawTime); - nTimeInSecs = mktime(timeInfo); + localtime_r(&RawTime, &timeInfo); + nTimeInSecs = mktime(&timeInfo); pMmsMsg->mmsAttrib.date = nTimeInSecs; // setting szMsgId @@ -354,7 +351,7 @@ void MmsComposeReadReportMessage(MmsMsg *pMmsMsg, const MSG_MESSAGE_INFO_S *pMsg MmsSetMsgAddressList(&pMmsMsg->mmsAttrib, pMsgInfo); if (pMmsMsg->mmsAttrib.szTo) - strncpy(pMmsMsg->mmsAttrib.szFrom, pMmsMsg->mmsAttrib.szTo, strlen(pMmsMsg->mmsAttrib.szTo)); + snprintf(pMmsMsg->mmsAttrib.szFrom, sizeof(pMmsMsg->mmsAttrib.szFrom), "%s", pMmsMsg->mmsAttrib.szTo); } msg_error_t MmsMakeMultipartThumbnailInfo(MMS_MULTIPART_DATA_S *pMultipart, char *thumbnail_path) @@ -555,22 +552,26 @@ bool MmsInsertPartToMmsData(MMS_MESSAGE_DATA_S *pMsgData, MMS_MULTIPART_DATA_S * if (isInsert == false) { MMS_ATTACH_S *attachment = NULL; attachment = (MMS_ATTACH_S *)calloc(sizeof(MMS_ATTACH_S), 1); - attachment->drmType = pMultipart->drmType; + if (attachment) { + attachment->drmType = pMultipart->drmType; - if (strlen(pMultipart->szContentType) > 0) { - snprintf(attachment->szContentType, sizeof(attachment->szContentType), "%s", pMultipart->szContentType); - attachment->mediatype = pMultipart->type; - } + if (strlen(pMultipart->szContentType) > 0) { + snprintf(attachment->szContentType, sizeof(attachment->szContentType), "%s", pMultipart->szContentType); + attachment->mediatype = pMultipart->type; + } - snprintf(attachment->szFilePath, sizeof(attachment->szFilePath), "%s", pMultipart->szFilePath); - snprintf(attachment->szFileName, sizeof(attachment->szFileName), "%s", pMultipart->szFileName); - attachment->fileSize = MsgGetFileSize(attachment->szFilePath); + snprintf(attachment->szFilePath, sizeof(attachment->szFilePath), "%s", pMultipart->szFilePath); + snprintf(attachment->szFileName, sizeof(attachment->szFileName), "%s", pMultipart->szFileName); + attachment->fileSize = MsgGetFileSize(attachment->szFilePath); - MSG_SEC_DEBUG("Insert Attach to attachment[%p] : path = [%s], name = [%s], ct = [%s], size = [%d]"\ - , attachment, attachment->szFilePath, attachment->szFileName, attachment->szContentType, attachment->fileSize); + MSG_SEC_DEBUG("Insert Attach to attachment[%p] : path = [%s], name = [%s], ct = [%s], size = [%d]"\ + , attachment, attachment->szFilePath, attachment->szFileName, attachment->szContentType, attachment->fileSize); - if (_MsgMmsAddAttachment(pMsgData, attachment) != MSG_SUCCESS) { - g_free(attachment); + if (_MsgMmsAddAttachment(pMsgData, attachment) != MSG_SUCCESS) { + g_free(attachment); + return false; + } + } else { return false; } } @@ -611,45 +612,52 @@ bool MmsInsertMixedPartToMmsData(MMS_MESSAGE_DATA_S *pMsgData, MMS_MULTIPART_DAT if (mediatype != MMS_SMIL_MEDIA_INVALID) { MMS_PAGE_S *pPage = (MMS_PAGE_S *)calloc(1, sizeof(MMS_PAGE_S)); MMS_MEDIA_S *media = (MMS_MEDIA_S *)calloc(1, sizeof(MMS_MEDIA_S)); + if (pPage && media) { + media->mediatype = mediatype; + media->drmType = pMultipart->drmType; + snprintf(media->szFilePath, sizeof(media->szFilePath), "%s", pMultipart->szFilePath); + snprintf(media->szFileName, sizeof(media->szFileName), "%s", pMultipart->szFileName); + snprintf(media->szContentID, sizeof(media->szContentID), "%s", pMultipart->szContentID); + snprintf(media->szContentLocation, sizeof(media->szContentLocation), "%s", pMultipart->szContentLocation); + snprintf(media->szContentType, sizeof(media->szContentType), "%s", pMultipart->szContentType); + + MSG_SEC_DEBUG("InsertPart to media[%p] type[%d] : path = [%s], name = [%s], cid = [%s], cl = [%s], ct = [%s]"\ + , media, mediatype, media->szFilePath, media->szFileName, media->szContentID, media->szContentLocation, media->szContentType); + + if (_MsgMmsAddMedia(pPage, media) != MSG_SUCCESS) { + g_free(pPage); + g_free(media); + return false; + } - media->mediatype = mediatype; - media->drmType = pMultipart->drmType; - snprintf(media->szFilePath, sizeof(media->szFilePath), "%s", pMultipart->szFilePath); - snprintf(media->szFileName, sizeof(media->szFileName), "%s", pMultipart->szFileName); - snprintf(media->szContentID, sizeof(media->szContentID), "%s", pMultipart->szContentID); - snprintf(media->szContentLocation, sizeof(media->szContentLocation), "%s", pMultipart->szContentLocation); - snprintf(media->szContentType, sizeof(media->szContentType), "%s", pMultipart->szContentType); - - MSG_SEC_DEBUG("InsertPart to media[%p] type[%d] : path = [%s], name = [%s], cid = [%s], cl = [%s], ct = [%s]"\ - , media, mediatype, media->szFilePath, media->szFileName, media->szContentID, media->szContentLocation, media->szContentType); - - if (_MsgMmsAddMedia(pPage, media) != MSG_SUCCESS) { - g_free(pPage); - g_free(media); - return false; - } - - if (_MsgMmsAddPage(pMsgData, pPage) != MSG_SUCCESS) { - g_free(pPage); - g_free(media); + if (_MsgMmsAddPage(pMsgData, pPage) != MSG_SUCCESS) { + g_free(pPage); + g_free(media); + return false; + } + } else { + if (pPage) g_free(pPage); + if (media) g_free(media); return false; } - } else { MMS_ATTACH_S *attachment = NULL; attachment = (MMS_ATTACH_S *)calloc(sizeof(MMS_ATTACH_S), 1); - - attachment->mediatype = pMultipart->type; - attachment->drmType = pMultipart->drmType; - snprintf(attachment->szContentType, sizeof(attachment->szContentType), "%s", pMultipart->szContentType); - snprintf(attachment->szFilePath, sizeof(attachment->szFilePath), "%s", pMultipart->szFilePath); - snprintf(attachment->szFileName, sizeof(attachment->szFileName), "%s", pMultipart->szFileName); - attachment->fileSize = MsgGetFileSize(attachment->szFilePath); - MSG_SEC_DEBUG("Insert Attach to attachment[%p] : path = [%s], name = [%s], ct = [%s], size = [%d]"\ - , attachment, attachment->szFilePath, attachment->szFileName, attachment->szContentType, attachment->fileSize); - - if (_MsgMmsAddAttachment(pMsgData, attachment) != MSG_SUCCESS) { - g_free(attachment); + if (attachment) { + attachment->mediatype = pMultipart->type; + attachment->drmType = pMultipart->drmType; + snprintf(attachment->szContentType, sizeof(attachment->szContentType), "%s", pMultipart->szContentType); + snprintf(attachment->szFilePath, sizeof(attachment->szFilePath), "%s", pMultipart->szFilePath); + snprintf(attachment->szFileName, sizeof(attachment->szFileName), "%s", pMultipart->szFileName); + attachment->fileSize = MsgGetFileSize(attachment->szFilePath); + MSG_SEC_DEBUG("Insert Attach to attachment[%p] : path = [%s], name = [%s], ct = [%s], size = [%d]"\ + , attachment, attachment->szFilePath, attachment->szFileName, attachment->szContentType, attachment->fileSize); + + if (_MsgMmsAddAttachment(pMsgData, attachment) != MSG_SUCCESS) { + g_free(attachment); + return false; + } + } else { return false; } } @@ -768,7 +776,7 @@ bool MmsConvertMsgData(MmsMsg *pMsg, MMS_MESSAGE_DATA_S *pMmsMsg) snprintf(szBuf, sizeof(szBuf), "%s", partHeader.param.szFileName); snprintf(partHeader.param.szFileName, sizeof(partHeader.param.szFileName), "%s%s", MSG_DATA_PATH, szBuf); - page = (MMS_PAGE_S *)calloc(1, sizeof(MMS_PAGE_S)); + page = (MMS_PAGE_S *)calloc(1, sizeof(MMS_PAGE_S)); if (page == NULL) { MSG_FATAL("page allocation error"); goto FREE_CATCH; @@ -902,19 +910,21 @@ int MmsUpdatePreviewData(MSG_MESSAGE_INFO_S *pMsgInfo) MSG_BEGIN(); char szFullPath[MSG_FILEPATH_LEN_MAX] = {0, }; - MmsMsg mmsMsg; - memset(&mmsMsg, 0, sizeof(MmsMsg)); + MmsMsg *mmsMsg = NULL; + unique_ptr<MmsMsg*, void(*)(MmsMsg**)> buf(&mmsMsg, unique_ptr_deleter); + mmsMsg = (MmsMsg *)new char[sizeof(MmsMsg)]; + memset(mmsMsg, 0x00, sizeof(MmsMsg)); MmsPluginStorage::instance()->getMmsRawFilePath(pMsgInfo->msgId, szFullPath, sizeof(szFullPath)); - MmsPluginDecoder::instance()->decodeMmsPdu(&mmsMsg, pMsgInfo->msgId, szFullPath); + MmsPluginDecoder::instance()->decodeMmsPdu(mmsMsg, pMsgInfo->msgId, szFullPath); {//make Preview info for APP - MmsPluginAppBase appBase(&mmsMsg); + MmsPluginAppBase appBase(mmsMsg); appBase.makePreviewInfo(pMsgInfo->msgId, true, szFullPath); appBase.getFirstPageTextFilePath(pMsgInfo->msgText, sizeof(pMsgInfo->msgText)); } - MmsReleaseMmsMsg(&mmsMsg); + MmsReleaseMmsMsg(mmsMsg); MSG_END(); return 0; } @@ -959,15 +969,16 @@ bool MmsConvertMmsData(MmsMsg *pMmsMsg, MMS_DATA_S *pMmsData) if (pMmsMsg->mmsAttrib.contentType == MIME_MULTIPART_RELATED || pMmsMsg->mmsAttrib.contentType == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED) { MMS_MULTIPART_DATA_S *pMultipart = MsgMmsCreateMultipart(); - - pMultipart->type = MIME_APPLICATION_SMIL; - snprintf(pMultipart->szContentType, sizeof(pMultipart->szContentType), "%s", "application/smil"); - snprintf(pMultipart->szContentID, sizeof(pMultipart->szContentID), "%s", pMmsMsg->msgBody.presentationType.szContentID); - snprintf(pMultipart->szContentLocation, sizeof(pMultipart->szContentLocation), "%s", pMmsMsg->msgBody.presentationType.szContentLocation); - snprintf(pMultipart->szFileName, sizeof(pMultipart->szFileName), "%s", pMmsMsg->msgBody.presentationType.param.szName); - snprintf(pMultipart->szFilePath, sizeof(pMultipart->szFilePath), MSG_DATA_PATH"%s", pMmsMsg->msgBody.presentationType.param.szFileName); - - pMmsData->smil = pMultipart; + if (pMultipart) { + pMultipart->type = MIME_APPLICATION_SMIL; + snprintf(pMultipart->szContentType, sizeof(pMultipart->szContentType), "%s", "application/smil"); + snprintf(pMultipart->szContentID, sizeof(pMultipart->szContentID), "%s", pMmsMsg->msgBody.presentationType.szContentID); + snprintf(pMultipart->szContentLocation, sizeof(pMultipart->szContentLocation), "%s", pMmsMsg->msgBody.presentationType.szContentLocation); + snprintf(pMultipart->szFileName, sizeof(pMultipart->szFileName), "%s", pMmsMsg->msgBody.presentationType.param.szName); + snprintf(pMultipart->szFilePath, sizeof(pMultipart->szFilePath), MSG_DATA_PATH"%s", pMmsMsg->msgBody.presentationType.param.szFileName); + + pMmsData->smil = pMultipart; + } } int partCnt = pMmsMsg->nPartCount; @@ -980,20 +991,22 @@ bool MmsConvertMmsData(MmsMsg *pMmsMsg, MMS_DATA_S *pMmsData) MMS_MULTIPART_DATA_S *pMultipart = MsgMmsCreateMultipart(); - pMultipart->type = (MimeType)multipart->type.type; + if (pMultipart) { + pMultipart->type = (MimeType)multipart->type.type; - snprintf(pMultipart->szContentType, sizeof(pMultipart->szContentType), "%s",MimeGetMimeStringFromMimeInt(multipart->type.type)); - snprintf(pMultipart->szContentID, sizeof(pMultipart->szContentID), "%s", multipart->type.szContentID); - snprintf(pMultipart->szContentLocation, sizeof(pMultipart->szContentLocation), "%s", multipart->type.szContentLocation); - snprintf(pMultipart->szFileName, sizeof(pMultipart->szFileName), "%s", multipart->type.param.szName); - snprintf(pMultipart->szFilePath, sizeof(pMultipart->szFilePath), "%s", multipart->pBody->szOrgFilePath); + snprintf(pMultipart->szContentType, sizeof(pMultipart->szContentType), "%s",MimeGetMimeStringFromMimeInt(multipart->type.type)); + snprintf(pMultipart->szContentID, sizeof(pMultipart->szContentID), "%s", multipart->type.szContentID); + snprintf(pMultipart->szContentLocation, sizeof(pMultipart->szContentLocation), "%s", multipart->type.szContentLocation); + snprintf(pMultipart->szFileName, sizeof(pMultipart->szFileName), "%s", multipart->type.param.szName); + snprintf(pMultipart->szFilePath, sizeof(pMultipart->szFilePath), "%s", multipart->pBody->szOrgFilePath); #ifdef __SUPPORT_DRM__ - if (multipart->type.drmInfo.drmType != MSG_DRM_TYPE_NONE) { - pMultipart->drmType = multipart->type.drmInfo.drmType; - } + if (multipart->type.drmInfo.drmType != MSG_DRM_TYPE_NONE) { + pMultipart->drmType = multipart->type.drmInfo.drmType; + } #endif - pMmsData->multipartlist = g_list_append(pMmsData->multipartlist, pMultipart); + pMmsData->multipartlist = g_list_append(pMmsData->multipartlist, pMultipart); + } } } @@ -1114,8 +1127,8 @@ bool MmsConvertMmsMsg(MmsMsg *pMmsMsg, MMS_DATA_S *pMmsData) char *MmsConvertAddressToOldStyle(MMSList *pAddressList) { MSG_BEGIN(); - int addrLen = 0; - int nAddressCnt = 0; + int addrLen = 0; + int nAddressCnt = 0; char pString[MSG_LOCALE_NAME_LEN + MSG_ADDR_LEN + 3] = {0, }; char *szCompose = NULL; @@ -1141,26 +1154,26 @@ char *MmsConvertAddressToOldStyle(MMSList *pAddressList) szCompose = (char *)calloc(addrLen + 1, 1); - // Address String copy - for (int i = 0; i < nAddressCnt; ++i) { + if (szCompose) { + // Address String copy + for (int i = 0; i < nAddressCnt; ++i) { + MMS_ADDRESS_DATA_S * pAddressData = (MMS_ADDRESS_DATA_S *)g_list_nth_data(pAddressList, i); - MMS_ADDRESS_DATA_S * pAddressData = (MMS_ADDRESS_DATA_S *)g_list_nth_data(pAddressList, i); + if (pAddressData) { + if (strlen(szCompose) > 0) + g_strlcat(szCompose, MSG_STR_ADDR_DELIMETER, addrLen + 1 - strlen(szCompose)); - if (pAddressData) { - if (strlen(szCompose) > 0) - strcat(szCompose, MSG_STR_ADDR_DELIMETER); + memset(pString, 0x00, (MSG_LOCALE_NAME_LEN + MSG_ADDR_LEN + 3) * sizeof(char)); + if (pAddressData->address_type == MSG_ADDRESS_TYPE_PLMN) { + snprintf(pString, MSG_LOCALE_NAME_LEN + MSG_ADDR_LEN + 3, "%s%s", pAddressData->address_val, "/TYPE=PLMN"); + MSG_DEBUG("%s", pString); + } else { + snprintf(pString, MSG_LOCALE_NAME_LEN + MSG_ADDR_LEN + 3, "%s", pAddressData->address_val); + } - memset(pString, 0x00, (MSG_LOCALE_NAME_LEN + MSG_ADDR_LEN + 3) * sizeof(char)); - if (pAddressData->address_type == MSG_ADDRESS_TYPE_PLMN) { - snprintf(pString, MSG_LOCALE_NAME_LEN + MSG_ADDR_LEN + 3, "%s%s", pAddressData->address_val, "/TYPE=PLMN"); - MSG_DEBUG("%s", pString); - } else { - snprintf(pString, MSG_LOCALE_NAME_LEN + MSG_ADDR_LEN + 3, "%s", pAddressData->address_val); + g_strlcat(szCompose, pString, addrLen + 1 - strlen(szCompose)); } - - strcat(szCompose, pString); } - } MSG_END(); diff --git a/plugin/mms_plugin/MmsPluginStorage.cpp b/plugin/mms_plugin/MmsPluginStorage.cpp index 81b85d9..2100138 100755 --- a/plugin/mms_plugin/MmsPluginStorage.cpp +++ b/plugin/mms_plugin/MmsPluginStorage.cpp @@ -18,6 +18,7 @@ #include <sys/stat.h> #include <errno.h> +#include "MsgCppTypes.h" #include "MsgException.h" #include "MsgUtilFile.h" #include "MsgMmsMessage.h" @@ -442,7 +443,7 @@ msg_error_t MmsPluginStorage::getMmsMessageId(msg_message_id_t selectedMsgId, Mm snprintf(sqlQuery, sizeof(sqlQuery), "SELECT MESSAGE_ID FROM %s WHERE MSG_ID = %d;", MMS_PLUGIN_MESSAGE_TABLE_NAME, selectedMsgId); - err = dbHandle->getTable(sqlQuery, &rowCnt); + err = dbHandle->getTable(sqlQuery, &rowCnt, NULL); if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { dbHandle->freeTable(); @@ -467,9 +468,9 @@ msg_error_t MmsPluginStorage::getMmsMessageId(msg_message_id_t selectedMsgId, Mm int MmsPluginStorage::getMmsVersion(msg_message_id_t selectedMsgId) { msg_error_t err = MSG_SUCCESS; - int rowCnt = 0; - int version = 0; + int rowCnt = 0; + int version = 0; MsgDbHandler *dbHandle = getDbHandle(); @@ -480,7 +481,7 @@ int MmsPluginStorage::getMmsVersion(msg_message_id_t selectedMsgId) snprintf(sqlQuery, sizeof(sqlQuery), "SELECT VERSION FROM %s WHERE MSG_ID = %d;", MMS_PLUGIN_MESSAGE_TABLE_NAME, selectedMsgId); - err = dbHandle->getTable(sqlQuery, &rowCnt); + err = dbHandle->getTable(sqlQuery, &rowCnt, NULL); if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { dbHandle->freeTable(); @@ -653,7 +654,7 @@ msg_error_t MmsPluginStorage::getMsgText(MMS_MESSAGE_DATA_S *pMmsMsg, char *pMsg pMedia = _MsgMmsGetMedia(pPage, j); - if (pMedia->mediatype == MMS_SMIL_MEDIA_TEXT) { + if (pMedia && pMedia->mediatype == MMS_SMIL_MEDIA_TEXT) { MimeType mimeType = MIME_UNKNOWN; MmsGetMimeTypeFromFileName(MIME_MAINTYPE_UNKNOWN, pMedia->szFilePath, &mimeType, NULL); @@ -1012,8 +1013,7 @@ msg_error_t MmsPluginStorage::getMultipartList(msg_message_id_t msgId, MMSList * MsgDbHandler *dbHandle = getDbHandle(); char sqlQuery[MAX_QUERY_LEN + 1]; - int rowCnt; - int index = 8; + int rowCnt = 0, index = 0; memset(sqlQuery, 0x00, sizeof(sqlQuery)); snprintf(sqlQuery, sizeof(sqlQuery), @@ -1021,7 +1021,7 @@ msg_error_t MmsPluginStorage::getMultipartList(msg_message_id_t msgId, MMSList * "FROM %s WHERE MSG_ID=%d;", MSGFW_MMS_MULTIPART_TABLE_NAME, msgId); - msg_error_t err = dbHandle->getTable(sqlQuery, &rowCnt); + msg_error_t err = dbHandle->getTable(sqlQuery, &rowCnt, &index); if (err == MSG_SUCCESS) { @@ -1314,9 +1314,11 @@ msg_error_t MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDI } {//make Preview info for APP - MmsPluginAppBase appBase(pMmsData); - appBase.makePreviewInfo(pMsgInfo->msgId, true, raw_filepath); - appBase.getFirstPageTextFilePath(pMsgInfo->msgText, sizeof(pMsgInfo->msgText)); + MmsPluginAppBase *appBase; + appBase = new MmsPluginAppBase(pMmsData); + appBase->makePreviewInfo(pMsgInfo->msgId, true, raw_filepath); + appBase->getFirstPageTextFilePath(pMsgInfo->msgText, sizeof(pMsgInfo->msgText)); + delete appBase; } } else if (pMsgInfo->msgType.subType == MSG_NOTIFICATIONIND_MMS) { @@ -1426,9 +1428,11 @@ msg_error_t MmsPluginStorage::updateMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SE } {//make Preview info for APP - MmsPluginAppBase appBase(pMmsData); - appBase.makePreviewInfo(pMsgInfo->msgId, true, raw_filepath); - appBase.getFirstPageTextFilePath(pMsgInfo->msgText, sizeof(pMsgInfo->msgText)); + MmsPluginAppBase *appBase; + appBase = new MmsPluginAppBase(pMmsData); + appBase->makePreviewInfo(pMsgInfo->msgId, true, raw_filepath); + appBase->getFirstPageTextFilePath(pMsgInfo->msgText, sizeof(pMsgInfo->msgText)); + delete appBase; } } @@ -1538,16 +1542,21 @@ msg_error_t MmsPluginStorage::updateMessage(MSG_MESSAGE_INFO_S *pMsgInfo) //update preview char szFullPath[MSG_FILEPATH_LEN_MAX] = {0, }; - MmsMsg mmsMsg; - memset(&mmsMsg, 0, sizeof(MmsMsg)); + MmsMsg *mmsMsg = NULL; + unique_ptr<MmsMsg*, void(*)(MmsMsg**)> buf(&mmsMsg, unique_ptr_deleter); + mmsMsg = (MmsMsg *)new char[sizeof(MmsMsg)]; + memset(mmsMsg, 0x00, sizeof(MmsMsg)); + MmsPluginStorage::instance()->getMmsRawFilePath(pMsgInfo->msgId, szFullPath, sizeof(szFullPath)); - MmsPluginDecoder::instance()->decodeMmsPdu(&mmsMsg, pMsgInfo->msgId, szFullPath); + MmsPluginDecoder::instance()->decodeMmsPdu(mmsMsg, pMsgInfo->msgId, szFullPath); {//make Preview info for APP - MmsPluginAppBase appBase(&mmsMsg); - appBase.makePreviewInfo(pMsgInfo->msgId, true, szFullPath); - appBase.getFirstPageTextFilePath(pMsgInfo->msgText, sizeof(pMsgInfo->msgText)); + MmsPluginAppBase *appBase; + appBase = new MmsPluginAppBase(mmsMsg); + appBase->makePreviewInfo(pMsgInfo->msgId, true, szFullPath); + appBase->getFirstPageTextFilePath(pMsgInfo->msgText, sizeof(pMsgInfo->msgText)); + delete appBase; } - MmsReleaseMmsMsg(&mmsMsg); + MmsReleaseMmsMsg(mmsMsg); MSG_END(); return 0; @@ -1581,7 +1590,7 @@ int MmsPluginStorage::checkDuplicateNotification(char* pszTrID, char* pszContent MSG_DEBUG("sqlQuery [%s]", sqlQuery); - err = dbHandle->getTable(sqlQuery, &rowCnt); + err = dbHandle->getTable(sqlQuery, &rowCnt, NULL); if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD) { dbHandle->freeTable(); diff --git a/plugin/mms_plugin/MmsPluginTextConvert.cpp b/plugin/mms_plugin/MmsPluginTextConvert.cpp index 58e1da4..bd79ac6 100755 --- a/plugin/mms_plugin/MmsPluginTextConvert.cpp +++ b/plugin/mms_plugin/MmsPluginTextConvert.cpp @@ -58,6 +58,11 @@ bool MmsPluginTextConvert(const char *pToCodeSet, const char *pFromCodeset, cons if (((UINT8)pSrc[0] == 0xFF && (UINT8)pSrc[1] == 0xFE) || ((UINT8)pSrc[0] == 0xFE && (UINT8)pSrc[1] == 0xFF)) { char *pTemp = (char *)calloc(1, srcLen + 1); + if (pTemp == NULL) { + MSG_DEBUG("fail to calloc"); + goto __CATCH; + } + memcpy(pTemp, pSrc, srcLen); for (int i = 0; i < srcLen - 1; i++) { @@ -71,7 +76,8 @@ bool MmsPluginTextConvert(const char *pToCodeSet, const char *pFromCodeset, cons if (MmsIsUtf8String((unsigned char *)pTemp+2, srcLen-2) == true) { MSG_DEBUG("UTF-8 string"); pDest = (char *)calloc(1, srcLen - 2 + 1); - strncpy(pDest, pTemp + 2, srcLen - 2); + if (pDest) + strncpy(pDest, pTemp + 2, srcLen - 2); bytes_written = srcLen - 2; if (pTemp) { diff --git a/plugin/mms_plugin/MmsPluginTransport.cpp b/plugin/mms_plugin/MmsPluginTransport.cpp index b055248..5af58cf 100755 --- a/plugin/mms_plugin/MmsPluginTransport.cpp +++ b/plugin/mms_plugin/MmsPluginTransport.cpp @@ -80,7 +80,8 @@ void MmsPluginTransport::submitRequest(const MSG_REQUEST_INFO_S *pReqInfo) reqItem.eHttpCmdType = eHTTP_CMD_GET_TRANSACTION; reqItem.getDataLen = pReqInfo->msgInfo.dataSize; reqItem.pGetData = (char *)malloc(reqItem.getDataLen); - memcpy(reqItem.pGetData, pReqInfo->msgInfo.msgData, reqItem.getDataLen); + if (reqItem.pGetData) + memcpy(reqItem.pGetData, pReqInfo->msgInfo.msgData, reqItem.getDataLen); MSG_MMS_VLD_INFO("%d, MMS Receive Auto Start %s->%s, Success", pReqInfo->msgInfo.msgId, pReqInfo->msgInfo.addressList[0].addressVal, (msisdn == NULL)?"ME":msisdn); break; @@ -104,7 +105,8 @@ void MmsPluginTransport::submitRequest(const MSG_REQUEST_INFO_S *pReqInfo) reqItem.eHttpCmdType = eHTTP_CMD_GET_TRANSACTION; reqItem.getDataLen = pReqInfo->msgInfo.dataSize; reqItem.pGetData = (char *)malloc(reqItem.getDataLen); - memcpy(reqItem.pGetData, pReqInfo->msgInfo.msgData, reqItem.getDataLen); + if (reqItem.pGetData) + memcpy(reqItem.pGetData, pReqInfo->msgInfo.msgData, reqItem.getDataLen); MSG_MMS_VLD_INFO("%d, MMS Receive Manual Start %s->%s, Success", pReqInfo->msgInfo.msgId, pReqInfo->msgInfo.addressList[0].addressVal, (msisdn == NULL)?"ME":msisdn); break; diff --git a/plugin/mms_plugin/MmsPluginUserAgent.cpp b/plugin/mms_plugin/MmsPluginUserAgent.cpp index 6e022d8..ff4d13b 100755 --- a/plugin/mms_plugin/MmsPluginUserAgent.cpp +++ b/plugin/mms_plugin/MmsPluginUserAgent.cpp @@ -288,7 +288,8 @@ MMS_NET_ERROR_T MmsPluginUaManager::submitHandler(mmsTranQEntity *qEntity) http_url = (char *)calloc(1, qEntity->getDataLen + 1); - memcpy(http_url, qEntity->pGetData, qEntity->getDataLen); + if (http_url) + memcpy(http_url, qEntity->pGetData, qEntity->getDataLen); request_info.url = http_url; diff --git a/plugin/mms_plugin/MmsPluginUtil.cpp b/plugin/mms_plugin/MmsPluginUtil.cpp index 4bcb74b..6db2c2c 100755 --- a/plugin/mms_plugin/MmsPluginUtil.cpp +++ b/plugin/mms_plugin/MmsPluginUtil.cpp @@ -31,7 +31,6 @@ using namespace std; - Mutex g_mx; CndVar g_cv; @@ -218,7 +217,7 @@ FILE *MmsFileOpen(char *pFileName) mode_t file_mode = (S_IRUSR | S_IWUSR); if (!pFileName) { - MSG_DEBUG("pFileName NULL: %s", strerror(errno)); + MSG_DEBUG("pFileName NULL: %s", g_strerror(errno)); return NULL; } @@ -227,19 +226,19 @@ FILE *MmsFileOpen(char *pFileName) FILE *pFile = MsgOpenFile(pFileName, "wb+"); if (pFile == NULL) { - MSG_FATAL("File Open Error: %s", strerror(errno)); + MSG_FATAL("File Open Error: %s", g_strerror(errno)); return NULL; } if (MsgFseek(pFile, 0L, SEEK_CUR) < 0) { MsgCloseFile(pFile); - MSG_DEBUG("File Read Error: %s", strerror(errno)); + MSG_DEBUG("File Read Error: %s", g_strerror(errno)); return NULL; } if (fchmod(fileno(pFile), file_mode) < 0) { MsgCloseFile(pFile); - MSG_DEBUG("File chmod Error: %s", strerror(errno)); + MSG_DEBUG("File chmod Error: %s", g_strerror(errno)); return NULL; } diff --git a/plugin/mms_plugin/include/MmsPluginCodecTypes.h b/plugin/mms_plugin/include/MmsPluginCodecTypes.h index d4b1566..0be998b 100755 --- a/plugin/mms_plugin/include/MmsPluginCodecTypes.h +++ b/plugin/mms_plugin/include/MmsPluginCodecTypes.h @@ -429,7 +429,7 @@ typedef struct _MsgType { int disposition; char szContentID[MSG_MSG_ID_LEN + 1]; char szContentLocation[MSG_MSG_ID_LEN + 1]; - char szOrgFilePath[MSG_FILEPATH_LEN_MAX]; + char szOrgFilePath[MSG_FILEPATH_LEN_MAX + 1]; MsgContentParam param; } MsgType; @@ -437,7 +437,7 @@ typedef struct _MsgType { struct _MsgBody { int offset; int size; - char szOrgFilePath[MSG_FILEPATH_LEN_MAX]; + char szOrgFilePath[MSG_FILEPATH_LEN_MAX + 1]; MsgType presentationType; MsgBody *pPresentationBody; diff --git a/plugin/sms_cdma_plugin/CMakeLists.txt b/plugin/sms_cdma_plugin/CMakeLists.txt index 82f9eef..bac61c7 100755 --- a/plugin/sms_cdma_plugin/CMakeLists.txt +++ b/plugin/sms_cdma_plugin/CMakeLists.txt @@ -8,7 +8,7 @@ IF("${CMAKE_BUILD_TYPE}" STREQUAL "") ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "") MESSAGE("Build type: ${CMAKE_BUILD_TYPE}") -SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -O0 -g -Wall") +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -O0 -g -Wall") ########################################################## # Define SMS Plugin diff --git a/plugin/sms_cdma_plugin/SmsCdmaPluginEventHandler.cpp b/plugin/sms_cdma_plugin/SmsCdmaPluginEventHandler.cpp index de38121..81362c7 100755 --- a/plugin/sms_cdma_plugin/SmsCdmaPluginEventHandler.cpp +++ b/plugin/sms_cdma_plugin/SmsCdmaPluginEventHandler.cpp @@ -506,7 +506,7 @@ void SmsPluginEventHandler::handleMsgIncoming(sms_trans_p2p_msg_s *p_p2p_msg) memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); /** convert to msgInfo */ convertTpduToMsginfo(p_p2p_msg, &msgInfo); @@ -688,7 +688,7 @@ void SmsPluginEventHandler::handleCbMsgIncoming(sms_trans_broadcast_msg_s *p_cb_ memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); /** convert to msgInfo */ convertTpduToMsginfo(p_cb_msg, &msgInfo); @@ -852,13 +852,13 @@ void SmsPluginEventHandler::handleWapMsgIncoming(sms_trans_p2p_msg_s *p_p2p_msg) int dataSize = 0; char* pUserData = NULL; char* pTmpUserData = NULL; - AutoPtr<char> dataBuf(&pUserData); - AutoPtr<char> dataBuf1(&pTmpUserData); + unique_ptr<char*, void(*)(char**)> dataBuf(&pUserData, unique_ptr_deleter); + unique_ptr<char*, void(*)(char**)> dataBuf1(&pTmpUserData, unique_ptr_deleter); MSG_MESSAGE_INFO_S msgInfo = {0,}; msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); dataSize = MakeWapUserData(msg.msgId, &pUserData); @@ -1092,7 +1092,8 @@ int SmsPluginEventHandler::MakeWapUserData(unsigned short msgId, char **ppTotalD MSG_DEBUG("totalSize [%d]", totalSize); - *ppTotalData = new char[totalSize]; + if (*ppTotalData == NULL) + *ppTotalData = new char[totalSize]; for (it = wapList[i].data.begin(); it != wapList[i].data.end(); it++) { memcpy(*ppTotalData+offset, it->second.data, it->second.length); diff --git a/plugin/sms_cdma_plugin/SmsCdmaPluginSetting.cpp b/plugin/sms_cdma_plugin/SmsCdmaPluginSetting.cpp index 9ca4712..501b1ae 100755 --- a/plugin/sms_cdma_plugin/SmsCdmaPluginSetting.cpp +++ b/plugin/sms_cdma_plugin/SmsCdmaPluginSetting.cpp @@ -102,7 +102,6 @@ void* SmsPluginSetting::initSimInfo(void *data) MSG_SEC_DEBUG("IMSI [%s]", imsi); } else { MSG_DEBUG("tel_get_sim_imsi() Error![%d]", tapiRet); - MsgSettingSetBool(MSG_NATIONAL_SIM, false); } MsgSettingSetString(MSG_SIM_IMSI, imsi); diff --git a/plugin/sms_cdma_plugin/SmsCdmaPluginStorage.cpp b/plugin/sms_cdma_plugin/SmsCdmaPluginStorage.cpp index a549b86..33ce7df 100755 --- a/plugin/sms_cdma_plugin/SmsCdmaPluginStorage.cpp +++ b/plugin/sms_cdma_plugin/SmsCdmaPluginStorage.cpp @@ -124,7 +124,7 @@ msg_error_t SmsPluginStorage::updateMsgDeliverStatus(MSG_MESSAGE_INFO_S *pMsgInf snprintf(sqlQuery, sizeof(sqlQuery), "SELECT * FROM %s WHERE MSG_ID = %d AND MSG_REF > 0;", MSGFW_SMS_REPORT_TABLE_NAME, msgId); - if (dbHandle->getTable(sqlQuery, &rowCnt) != MSG_SUCCESS) + if (dbHandle->getTable(sqlQuery, &rowCnt, NULL) != MSG_SUCCESS) return MSG_ERR_DB_GETTABLE; MSG_DEBUG("Selected row count = [%d]", rowCnt); @@ -561,7 +561,7 @@ msg_error_t SmsPluginStorage::getRegisteredPushEvent(char* pPushHeader, int *cou { msg_error_t err = MSG_SUCCESS; - int rowCnt = 0, index = 3; + int rowCnt = 0, index = 0; MsgDbHandler *dbHandle = getDbHandle(); @@ -571,7 +571,7 @@ msg_error_t SmsPluginStorage::getRegisteredPushEvent(char* pPushHeader, int *cou snprintf(sqlQuery, sizeof(sqlQuery), "SELECT CONTENT_TYPE, APP_ID, APPCODE FROM %s", MSGFW_PUSH_CONFIG_TABLE_NAME); - err = dbHandle->getTable(sqlQuery, &rowCnt); + err = dbHandle->getTable(sqlQuery, &rowCnt, &index); MSG_DEBUG("rowCnt: %d", rowCnt); if (err == MSG_ERR_DB_NORECORD) { diff --git a/plugin/sms_cdma_plugin/SmsCdmaPluginUAManager.cpp b/plugin/sms_cdma_plugin/SmsCdmaPluginUAManager.cpp index 1518cba..986e6f6 100755 --- a/plugin/sms_cdma_plugin/SmsCdmaPluginUAManager.cpp +++ b/plugin/sms_cdma_plugin/SmsCdmaPluginUAManager.cpp @@ -61,7 +61,7 @@ void SmsPluginUAManager::run() unlock(); request.msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&request.msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&request.msgInfo.addressList, unique_ptr_deleter); try { diff --git a/plugin/sms_cdma_plugin/SmsCdmaPluginWapPushHandler.cpp b/plugin/sms_cdma_plugin/SmsCdmaPluginWapPushHandler.cpp index 4a1524a..caec114 100755 --- a/plugin/sms_cdma_plugin/SmsCdmaPluginWapPushHandler.cpp +++ b/plugin/sms_cdma_plugin/SmsCdmaPluginWapPushHandler.cpp @@ -781,21 +781,21 @@ void SmsPluginWapPushHandler::handleWapPushMsg(const char *pUserData, int DataSi unsigned long PDUTypeDataLen = DataSize; char* pPushHeader = NULL; - AutoPtr<char> pushHeaderBuf(&pPushHeader); + unique_ptr<char*, void(*)(char**)> pushHeaderBuf(&pPushHeader, unique_ptr_deleter); unsigned long pushHeaderLen = 0; char* pPushBody = NULL; - AutoPtr<char> PushBodyBuf(&pPushBody); + unique_ptr<char*, void(*)(char**)> PushBodyBuf(&pPushBody, unique_ptr_deleter); unsigned long pushBodyLen = 0; unsigned long iPDU = 1; char* pWspHeader = NULL; - AutoPtr<char> WspHeaderBuf(&pWspHeader); + unique_ptr<char*, void(*)(char**)> WspHeaderBuf(&pWspHeader, unique_ptr_deleter); unsigned long wspHeaderLen = 0; char* pWspBody = NULL; - AutoPtr<char> WspBodyBuf(&pWspBody); + unique_ptr<char*, void(*)(char**)> WspBodyBuf(&pWspBody, unique_ptr_deleter); unsigned long wspBodyLen = 0; /** pass PDU type */ @@ -1361,7 +1361,7 @@ void SmsPluginWapPushHandler::handleMMSNotification(const char *pPushBody, int P memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); createMsgInfo(&msgInfo); @@ -1533,7 +1533,7 @@ void SmsPluginWapPushHandler::handleSIMessage(char* pPushBody, int PushBodyLen, memset(&msgInfo, 0, sizeof(MSG_MESSAGE_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); createMsgInfo(&msgInfo); @@ -1664,7 +1664,7 @@ void SmsPluginWapPushHandler::handleSLMessage(char* pPushBody, int PushBodyLen, memset(&msgInfo, 0, sizeof(MSG_MESSAGE_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); createMsgInfo(&msgInfo); @@ -1788,7 +1788,7 @@ void SmsPluginWapPushHandler::handleCOMessage(char* pPushBody, int PushBodyLen, memset(&msgInfo, 0, sizeof(MSG_MESSAGE_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); createMsgInfo(&msgInfo); @@ -1827,7 +1827,7 @@ void SmsPluginWapPushHandler::handleDrmVer1(char* pPushBody, int PushBodyLen) #if MSG_DRM_SUPPORT int drmRt = DRM_RETURN_SUCCESS; char* cid = NULL; - AutoPtr<char> buf(&cid); + unique_ptr<char*, void(*)(char**)> buf(&cid, unique_ptr_deleter); MSG_DEBUG("Received DRM RIGHTS OBJECT Type WAP Push Message."); drm_request_type_e request_type = DRM_REQUEST_TYPE_REGISTER_LICENSE; @@ -2150,12 +2150,12 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un unsigned long currentLength; char* encodedHeader = NULL; - AutoPtr<char> encodedHeaderbuf(&encodedHeader); + unique_ptr<char*, void(*)(char**)> encodedHeaderbuf(&encodedHeader, unique_ptr_deleter); char* outTemper = NULL; char* temper = NULL; - AutoPtr<char> temperbuf(&temper); + unique_ptr<char*, void(*)(char**)> temperbuf(&temper, unique_ptr_deleter); unsigned char track; unsigned long iEncodedHeader = 0; @@ -2181,7 +2181,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un for (loop = 0 ; loop<(int)encodedHeaderLen; loop++) { char szTempBuf[5]; szTempBuf[0] = 0x00; - sprintf( szTempBuf, "%2X ", sEncodedHeader[loop] ); + snprintf( szTempBuf, sizeof(szTempBuf), "%2X ", sEncodedHeader[loop] ); if (AcStrlen( szBuf ) + 7 < 64) { strncat( szBuf, szTempBuf, sizeof(szBuf)-AcStrlen(szBuf)-1 ); @@ -2389,7 +2389,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un /* If parameter exist */ if (iField < fieldValueLen) { char* param = NULL; - AutoPtr<char> parambuf(¶m); + unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter); wspHeaderDecodeQValue( fieldValueLen - iField, fieldValue + iField, ¶m); strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); } @@ -2496,7 +2496,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un /* If there is a parameter */ if (tempLen < fieldValueLen) { char* param = NULL; - AutoPtr<char> parambuf(¶m); + unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter); wspHeaderDecodeParameter( fieldValue + tempLen, fieldValueLen - tempLen, ¶m); if (param != NULL) { strncat( (char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1); @@ -2542,7 +2542,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un if (tempLen < fieldValueLen) { char* param = NULL; - AutoPtr<char> parambuf(¶m); + unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter); wspHeaderDecodeQValue( fieldValueLen - tempLen, fieldValue + tempLen, ¶m ); strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); } @@ -2568,7 +2568,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un AcSprintf( (char*)temp, "%u", (unsigned int)fieldValue[1]); else */ - sprintf( (char*)temp, "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue, fieldValueLen )); + snprintf( (char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue, fieldValueLen )); strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); } break; @@ -2610,7 +2610,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un AcSprintf( (char*)temp, "%u", (unsigned int)fieldValue[0]); else */ - sprintf( (char*)temp, "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue, fieldValueLen )); + snprintf( (char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue, fieldValueLen )); strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1); } break; @@ -2631,7 +2631,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un case 0x12 : { char* decodedString = NULL; - AutoPtr<char> decodedStringbuf(&decodedString); + unique_ptr<char*, void(*)(char**)> decodedStringbuf(&decodedString, unique_ptr_deleter); wspHeaderDecodeDateValue( fieldValueLen, fieldValue, &decodedString); strncat( (char*)temper, (char*)decodedString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1 ); } @@ -2665,7 +2665,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un case 0x21 : if (fieldValue[0] == 0x80) { char* addString = NULL; - AutoPtr<char> addStringbuf(&addString); + unique_ptr<char*, void(*)(char**)> addStringbuf(&addString, unique_ptr_deleter); wspHeaderDecodeAuth(fieldValueLen, fieldValue, &addString ); strncat( (char*)temper, addString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); } else { @@ -2674,7 +2674,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un strncat( (char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); if (iField < fieldValueLen) { char* param = NULL; - AutoPtr<char> parambuf(¶m); + unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter); wspHeaderDecodeParameter( fieldValue + 1, fieldValueLen - 1, ¶m ); if (param != NULL) { strncat( (char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); @@ -2694,7 +2694,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un break; if (fieldValue[0] == 0x80) { char* addString = NULL; - AutoPtr<char> addStringbuf(&addString); + unique_ptr<char*, void(*)(char**)> addStringbuf(&addString, unique_ptr_deleter); wspHeaderDecodeChallenge(fieldValueLen, fieldValue, &addString ); strncat( (char*)temper, addString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); } else { @@ -2711,7 +2711,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un if (iField < fieldValueLen) { char* param = NULL; - AutoPtr<char> parambuf(¶m); + unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter); wspHeaderDecodeParameter( fieldValue + iField, fieldValueLen - iField, ¶m ); if (param != NULL) { strncat( (char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); @@ -2737,7 +2737,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un */ last = first + contentsLength - 1; - sprintf( (char*)temp, "%u-%u/%u", (unsigned int)first, (unsigned int)last, (unsigned int)len ); + snprintf( (char*)temp, sizeof(temp), "%u-%u/%u", (unsigned int)first, (unsigned int)last, (unsigned int)len ); strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); } break; @@ -2746,7 +2746,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un case 0x08 : { char* cacheString = NULL; - AutoPtr<char> cacheStringbuf(&cacheString); + unique_ptr<char*, void(*)(char**)> cacheStringbuf(&cacheString, unique_ptr_deleter); wspHeaderDecodeCacheControl( fieldValue, fieldValueLen, &cacheString ); strncat( (char*)temper, (char*)cacheString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); @@ -2760,7 +2760,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un } else { if (1 < fieldValueLen) { char* param = NULL; - AutoPtr<char> parambuf(¶m); + unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter); wspHeaderDecodeParameter( fieldValue, fieldValueLen, ¶m ); if (param != NULL) { @@ -2792,7 +2792,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un first = wspRetriveUintvarDecode( fieldValue, &iField ); last = wspRetriveUintvarDecode( fieldValue, &iField ); - sprintf( (char*)temp, "%u-%u", (unsigned int)first, (unsigned int)last ); + snprintf( (char*)temp, sizeof(temp), "%u-%u", (unsigned int)first, (unsigned int)last ); strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); } if (fieldValue[0] == 0x81) { @@ -2801,7 +2801,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un suffix = wspRetriveUintvarDecode( fieldValue, &iField ); - sprintf( (char*)temp, "-%u", (unsigned int)suffix ); + snprintf( (char*)temp, sizeof(temp), "-%u", (unsigned int)suffix ); } break; @@ -2809,7 +2809,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un case 0x25 : if (fieldValue[0] == 0x80) { char* temp = NULL; - AutoPtr<char> tempbuf(&temp); + unique_ptr<char*, void(*)(char**)> tempbuf(&temp, unique_ptr_deleter); wspHeaderDecodeDateValue( fieldValueLen - 1, fieldValue + 1, &temp ); strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); @@ -2818,7 +2818,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un if (fieldValue[0] == 0x81) { unsigned char temp[16]; - sprintf( (char*)temp, "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue,fieldValueLen )); + snprintf( (char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue,fieldValueLen )); strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); } break; @@ -2873,7 +2873,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un if (1 < fieldValueLen) { char* param = NULL; - AutoPtr<char> parambuf(¶m); + unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter); wspHeaderDecodeParameter( fieldValue + 1, fieldValueLen - 1, ¶m ); if (param != NULL) { @@ -2902,7 +2902,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un if (fieldValueLen > ( AcStrlen( (char*)(fieldValue + 1)) + 1 )) { /* copy warn-date */ char* decodedString = NULL; - AutoPtr<char> decodedStringbuf(&decodedString); + unique_ptr<char*, void(*)(char**)> decodedStringbuf(&decodedString, unique_ptr_deleter); wspHeaderDecodeDateValue( fieldValueLen - ( AcStrlen( (char*)(fieldValue + 1)) + 2 ), fieldValue + AcStrlen( (char*)(fieldValue + 1)) + 1, &decodedString ); strncat( (char*)temp, (char*)decodedString, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)temp)-1 ); } diff --git a/plugin/sms_cdma_plugin/include/SmsCdmaPluginEventHandler.h b/plugin/sms_cdma_plugin/include/SmsCdmaPluginEventHandler.h index 2abf4c9..54b304e 100755 --- a/plugin/sms_cdma_plugin/include/SmsCdmaPluginEventHandler.h +++ b/plugin/sms_cdma_plugin/include/SmsCdmaPluginEventHandler.h @@ -125,7 +125,6 @@ private: int MakeWapUserData(unsigned short msgId, char **ppTotalData); bool checkCbOpt(sms_trans_svc_ctg_t svc_ctg); - std::list<MSG_CB_DUPLICATE_S> duplicateCb; }; diff --git a/plugin/sms_plugin/CMakeLists.txt b/plugin/sms_plugin/CMakeLists.txt index d4129c9..32fc48c 100755 --- a/plugin/sms_plugin/CMakeLists.txt +++ b/plugin/sms_plugin/CMakeLists.txt @@ -8,7 +8,7 @@ IF("${CMAKE_BUILD_TYPE}" STREQUAL "") ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "") MESSAGE("Build type: ${CMAKE_BUILD_TYPE}") -SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -O0 -g -Wall") +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -O2 -g -Wall") ########################################################## # Define SMS Plugin @@ -42,8 +42,7 @@ INCLUDE_DIRECTORIES( ) INCLUDE(FindPkgConfig) -pkg_check_modules(sms_plugin_pkgs REQUIRED glib-2.0 tapi libxml-2.0 libwbxml2 dlog vconf gio-2.0 db-util) -#capi-telephony +pkg_check_modules(sms_plugin_pkgs REQUIRED glib-2.0 tapi libxml-2.0 libwbxml2 dlog vconf gio-2.0 db-util capi-telephony) FOREACH(flag ${sms_plugin_pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") diff --git a/plugin/sms_plugin/SmsPluginCallback.cpp b/plugin/sms_plugin/SmsPluginCallback.cpp index e0fa5c6..b3b04ff 100755 --- a/plugin/sms_plugin/SmsPluginCallback.cpp +++ b/plugin/sms_plugin/SmsPluginCallback.cpp @@ -465,7 +465,7 @@ void TapiEventGetSimMsg(TapiHandle *handle, int result, void *data, void *user_d msgInfo.storageId = MSG_STORAGE_SIM; msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); SmsPluginEventHandler::instance()->convertTpduToMsginfo(&tpdu, &msgInfo); @@ -527,7 +527,7 @@ void TapiEventGetSimMsg(TapiHandle *handle, int result, void *data, void *user_d MSG_DEBUG("msgInfo.msgType.mainType : %d", msgInfo.msgType.mainType); MSG_DEBUG("msgInfo.msgType.subType : %d", msgInfo.msgType.subType); MSG_DEBUG("msgInfo.msgType.classType : %d", msgInfo.msgType.classType); - MSG_DEBUG("msgInfo.displayTime : %s", ctime(&msgInfo.displayTime)); + MSG_DEBUG("msgInfo.displayTime : %d", msgInfo.displayTime); MSG_DEBUG("msgInfo.dataSize : %d", msgInfo.dataSize); if (msgInfo.bTextSms == true) MSG_SEC_DEBUG("msgInfo.msgText : %s", msgInfo.msgText); @@ -885,7 +885,7 @@ void TapiEventGetCBConfig(TapiHandle *handle, int result, void *data, void *user cbOpt.bReceive = (bool)pCBConfig->CBEnabled; - cbOpt.maxSimCnt = pCBConfig->MsgIdMaxCount; + cbOpt.maxSimCnt = TAPI_NETTEXT_SMS_CBMI_LIST_SIZE_MAX; cbOpt.simIndex = simIndex; @@ -1085,30 +1085,34 @@ void TapiEventGetSimServiceTable(TapiHandle *handle, int result, void *data, voi } else { err = MsgSettingSetBool(sstKey, false); } + MSG_DEBUG("Setting result = [%d]", err); if (svct->table.sst.service[TAPI_SIM_SST_MO_SMS_CTRL_BY_SIM] == 1){ err = MsgSettingSetBool(moCtrlKey, true); } else { err = MsgSettingSetBool(moCtrlKey, false); } + MSG_DEBUG("Setting result = [%d]", err); + } else if (svct->sim_type == TAPI_SIM_CARD_TYPE_USIM) { if (svct->table.sst.service[TAPI_SIM_UST_SMS] == 1) { err = MsgSettingSetBool(sstKey, true); } else { err = MsgSettingSetBool(sstKey, false); } + MSG_DEBUG("Setting result = [%d]", err); if (svct->table.sst.service[TAPI_SIM_UST_MO_SMS_CTRL] == 1){ err = MsgSettingSetBool(moCtrlKey, true); } else { err = MsgSettingSetBool(moCtrlKey, false); } + MSG_DEBUG("Setting result = [%d]", err); + } else { MSG_DEBUG("Unknown SIM type value"); } - MSG_DEBUG("Setting result = [%d]", err); - SmsPluginSetting::instance()->setResultFromSim(bRet); } @@ -1253,7 +1257,7 @@ void TapiEventNetworkStatusChange(TapiHandle *handle, const char *noti_id, void TelNetworkServiceType_t *type = (TelNetworkServiceType_t *)data; - MSG_INFO("network status type [%d]", *type); + MSG_INFO("network status type [%d], simIndex [%d]", *type, (int)user_data); if (*type > TAPI_NETWORK_SERVICE_TYPE_SEARCH) { SmsPluginEventHandler::instance()->handleResendMessage(); // Call Event Handler @@ -1322,7 +1326,7 @@ void SmsPluginCallback::registerEvent() MSG_DEBUG("tel_register_noti_event is failed : [%s]", TAPI_NOTI_SAT_MO_SM_CONTROL_RESULT); if (tel_register_noti_event(pTapiHandle, TAPI_NOTI_SIM_STATUS, TapiEventSimStatusChange, NULL) != TAPI_API_SUCCESS) MSG_DEBUG("tel_register_noti_event is failed : [%s]", TAPI_NOTI_SIM_STATUS); - if (tel_register_noti_event(pTapiHandle, TAPI_PROP_NETWORK_SERVICE_TYPE, TapiEventNetworkStatusChange, NULL) != TAPI_API_SUCCESS) + if (tel_register_noti_event(pTapiHandle, TAPI_PROP_NETWORK_SERVICE_TYPE, TapiEventNetworkStatusChange, (void*)simIndex) != TAPI_API_SUCCESS) MSG_DEBUG("tel_register_noti_event is failed : [%s]", TAPI_PROP_NETWORK_SERVICE_TYPE); if (tel_register_noti_event(pTapiHandle, TAPI_NOTI_SIM_REFRESHED, TapiEventSimRefreshed, NULL) != TAPI_API_SUCCESS) MSG_DEBUG("tel_register_noti_event is failed : [%s]", TAPI_NOTI_SIM_REFRESHED); diff --git a/plugin/sms_plugin/SmsPluginCbMsgHandler.cpp b/plugin/sms_plugin/SmsPluginCbMsgHandler.cpp index ecacdf8..ce9e959 100755 --- a/plugin/sms_plugin/SmsPluginCbMsgHandler.cpp +++ b/plugin/sms_plugin/SmsPluginCbMsgHandler.cpp @@ -101,7 +101,7 @@ void SmsPluginCbMsgHandler::handleCbMsg(TapiHandle *handle, TelSmsCbMsg_t *pCbMs int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle); - if (!checkCbOpt(CbMsgPage, &bJavaMsg, simIndex)) + if (!checkCbOpt(&CbMsgPage, &bJavaMsg, simIndex)) { MSG_DEBUG("The CB Msg is not supported by option."); return; @@ -115,26 +115,30 @@ void SmsPluginCbMsgHandler::handleCbMsg(TapiHandle *handle, TelSmsCbMsg_t *pCbMs // Check CB Pages - unsigned char pageCnt = checkCbPage(CbMsgPage); + unsigned char pageCnt = checkCbPage(&CbMsgPage); if (pageCnt == CbMsgPage.pageHeader.totalPages) { MSG_DEBUG("RECEIVED LAST MSG : %d", pageCnt); - SMS_CBMSG_S cbMsg = {0,}; + SMS_CBMSG_S *cbMsg = NULL; + unique_ptr<SMS_CBMSG_S*, void(*)(SMS_CBMSG_S**)> buf(&cbMsg, unique_ptr_deleter); + cbMsg = (SMS_CBMSG_S *)new char[sizeof(SMS_CBMSG_S)]; + memset(cbMsg, 0x00, sizeof(SMS_CBMSG_S)); + MSG_MESSAGE_INFO_S msgInfo; /** initialize msgInfo */ memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); // Make CB Msg Structure - MakeCbMsg(CbMsgPage, &cbMsg); + MakeCbMsg(&CbMsgPage, cbMsg); // Convert to MSG_MESSAGE_INFO_S - convertCbMsgToMsginfo(&cbMsg, &msgInfo, simIndex); + convertCbMsgToMsginfo(cbMsg, &msgInfo, simIndex); // Add CB Msg into DB msg_error_t err = MSG_SUCCESS; @@ -146,13 +150,13 @@ void SmsPluginCbMsgHandler::handleCbMsg(TapiHandle *handle, TelSmsCbMsg_t *pCbMs MSG_CB_MSG_S cbOutMsg = {0, }; cbOutMsg.type = MSG_CB_SMS; - cbOutMsg.receivedTime = cbMsg.recvTime; + cbOutMsg.receivedTime = cbMsg->recvTime; cbOutMsg.serialNum = encodeCbSerialNum (CbMsgPage.pageHeader.serialNum); - cbOutMsg.messageId = cbMsg.msgId; + cbOutMsg.messageId = cbMsg->msgId; cbOutMsg.dcs = CbMsgPage.pageHeader.dcs.rawData; memset (cbOutMsg.cbText, 0x00, sizeof(cbOutMsg.cbText)); - cbOutMsg.cbTextLen= convertTextToUtf8((unsigned char*)cbOutMsg.cbText, sizeof(cbOutMsg.cbText), &cbMsg); + cbOutMsg.cbTextLen= convertTextToUtf8((unsigned char*)cbOutMsg.cbText, sizeof(cbOutMsg.cbText), cbMsg); memset(cbOutMsg.language_type, 0x00, sizeof(cbOutMsg.language_type)); memcpy(cbOutMsg.language_type, CbMsgPage.pageHeader.dcs.iso639Lang, 3); err = SmsPluginEventHandler::instance()->callbackCBMsgIncoming(&cbOutMsg, &msgInfo); @@ -176,9 +180,7 @@ void SmsPluginCbMsgHandler::handleCbMsg(TapiHandle *handle, TelSmsCbMsg_t *pCbMs } #endif // Remove From List - removeFromPageList(CbMsgPage); - - + removeFromPageList(&CbMsgPage); } MSG_END(); } @@ -200,7 +202,7 @@ void SmsPluginCbMsgHandler::handleEtwsMsg(TapiHandle *handle, TelSmsEtwsMsg_t *p return; } DecodeEtwsMsg(pEtwsMsg, &etwsPn); - //convertEtwsMsgToMsginfo(CbMsgPage, &msgInfo, simIndex); + //convertEtwsMsgToMsginfo(&CbMsgPage, &msgInfo, simIndex); cbOutMsg.type = MSG_ETWS_SMS; cbOutMsg.receivedTime = etwsPn.recvTime; @@ -565,7 +567,7 @@ int SmsPluginCbMsgHandler::CMAS_class(unsigned short message_id) return ret; } -bool SmsPluginCbMsgHandler::checkCbOpt(SMS_CBMSG_PAGE_S CbPage, bool *pJavaMsg, msg_sim_slot_id_t simIndex) +bool SmsPluginCbMsgHandler::checkCbOpt(SMS_CBMSG_PAGE_S *CbPage, bool *pJavaMsg, msg_sim_slot_id_t simIndex) { bool bReceive = false; char keyName[MAX_VCONFKEY_NAME_LEN]; @@ -624,9 +626,9 @@ bool SmsPluginCbMsgHandler::checkCbOpt(SMS_CBMSG_PAGE_S CbPage, bool *pJavaMsg, MsgId_from = cbChannelInfo.channelInfo[i].from; MsgId_to = cbChannelInfo.channelInfo[i].to; - if (bActivate == true && CbPage.pageHeader.msgId >= MsgId_from && CbPage.pageHeader.msgId <= MsgId_to) + if (bActivate == true && CbPage->pageHeader.msgId >= MsgId_from && CbPage->pageHeader.msgId <= MsgId_to) { - MSG_DEBUG("FIND CHANNEL = [%d]", CbPage.pageHeader.msgId); + MSG_DEBUG("FIND CHANNEL = [%d]", CbPage->pageHeader.msgId); return true; } } @@ -634,7 +636,7 @@ bool SmsPluginCbMsgHandler::checkCbOpt(SMS_CBMSG_PAGE_S CbPage, bool *pJavaMsg, return false; } -unsigned char SmsPluginCbMsgHandler::checkCbPage(SMS_CBMSG_PAGE_S CbPage) +unsigned char SmsPluginCbMsgHandler::checkCbPage(SMS_CBMSG_PAGE_S *CbPage) { unsigned char currPageCnt = 0; @@ -653,17 +655,17 @@ unsigned char SmsPluginCbMsgHandler::checkCbPage(SMS_CBMSG_PAGE_S CbPage) } #endif - if (CbPage.pageHeader.totalPages > 0) + if (CbPage->pageHeader.totalPages > 0) { for (unsigned int i = 0; i < pageList.size(); i++) { - if (pageList[i].geoScope == CbPage.pageHeader.serialNum.geoScope && pageList[i].msgCode == CbPage.pageHeader.serialNum.msgCode) + if (pageList[i].geoScope == CbPage->pageHeader.serialNum.geoScope && pageList[i].msgCode == CbPage->pageHeader.serialNum.msgCode) { MSG_DEBUG("geoScope [%d], msgCode [%d]", pageList[i].geoScope, pageList[i].msgCode); - if (pageList[i].msgId == CbPage.pageHeader.msgId) + if (pageList[i].msgId == CbPage->pageHeader.msgId) { - int updateNum = CbPage.pageHeader.serialNum.updateNum - pageList[i].updateNum; + int updateNum = CbPage->pageHeader.serialNum.updateNum - pageList[i].updateNum; if (updateNum > 0) // New Message Content { @@ -671,20 +673,20 @@ unsigned char SmsPluginCbMsgHandler::checkCbPage(SMS_CBMSG_PAGE_S CbPage) } else if (updateNum == 0) // Same Message Content { - if (pageList[i].data.count(CbPage.pageHeader.page) != 0) + if (pageList[i].data.count(CbPage->pageHeader.page) != 0) { - MSG_DEBUG("The Page Number already exists [%d]", CbPage.pageHeader.page); + MSG_DEBUG("The Page Number already exists [%d]", CbPage->pageHeader.page); return 0; } - pair<unsigned char, SMS_CBMSG_PAGE_S> newData(CbPage.pageHeader.page, CbPage); + pair<unsigned char, SMS_CBMSG_PAGE_S> newData(CbPage->pageHeader.page, *CbPage); pageList[i].data.insert(newData); - MSG_DEBUG("PAGE DATA : %s", CbPage.pageData); + MSG_DEBUG("PAGE DATA : %s", CbPage->pageData); MSG_DEBUG("PAIR DATA [%d] : %s", newData.first, newData.second.pageData); pageList[i].pageCnt++; - pageList[i].totalSize += CbPage.pageLength; + pageList[i].totalSize += CbPage->pageLength; currPageCnt = pageList[i].pageCnt; @@ -701,7 +703,7 @@ unsigned char SmsPluginCbMsgHandler::checkCbPage(SMS_CBMSG_PAGE_S CbPage) } } - if (bFind == false || CbPage.pageHeader.totalPages == 1) + if (bFind == false || CbPage->pageHeader.totalPages == 1) { addToPageList(CbPage); return 1; @@ -711,24 +713,24 @@ unsigned char SmsPluginCbMsgHandler::checkCbPage(SMS_CBMSG_PAGE_S CbPage) } -void SmsPluginCbMsgHandler::MakeCbMsg(SMS_CBMSG_PAGE_S CbPage, SMS_CBMSG_S *pCbMsg) +void SmsPluginCbMsgHandler::MakeCbMsg(SMS_CBMSG_PAGE_S *CbPage, SMS_CBMSG_S *pCbMsg) { - pCbMsg->cbMsgType = CbPage.cbMsgType; - pCbMsg->msgId = CbPage.pageHeader.msgId; - pCbMsg->classType = CbPage.pageHeader.dcs.classType; - pCbMsg->codingScheme = CbPage.pageHeader.dcs.codingScheme; - pCbMsg->recvTime = CbPage.pageHeader.recvTime; + pCbMsg->cbMsgType = CbPage->cbMsgType; + pCbMsg->msgId = CbPage->pageHeader.msgId; + pCbMsg->classType = CbPage->pageHeader.dcs.classType; + pCbMsg->codingScheme = CbPage->pageHeader.dcs.codingScheme; + pCbMsg->recvTime = CbPage->pageHeader.recvTime; cbPageMap::iterator it; int offset = 0; for (unsigned int i = 0; i < pageList.size(); i++) { - if (pageList[i].geoScope == CbPage.pageHeader.serialNum.geoScope && pageList[i].msgCode == CbPage.pageHeader.serialNum.msgCode) + if (pageList[i].geoScope == CbPage->pageHeader.serialNum.geoScope && pageList[i].msgCode == CbPage->pageHeader.serialNum.msgCode) { MSG_DEBUG("geoScope [%d], msgCode [%d]", pageList[i].geoScope, pageList[i].msgCode); - if (pageList[i].msgId == CbPage.pageHeader.msgId) + if (pageList[i].msgId == CbPage->pageHeader.msgId) { for (it = pageList[i].data.begin(); it != pageList[i].data.end(); it++) @@ -819,7 +821,7 @@ void SmsPluginCbMsgHandler::convertCbMsgToMsginfo(SMS_CBMSG_S *pCbMsg, MSG_MESSA pMsgInfo->msgPort.srcPort = 0; pMsgInfo->displayTime = pCbMsg->recvTime; - MSG_DEBUG("recvTime is %s", ctime(&pMsgInfo->displayTime)); + MSG_DEBUG("recvTime is %d", pMsgInfo->displayTime); int bufSize = pCbMsg->msgLength*2; @@ -872,16 +874,16 @@ void SmsPluginCbMsgHandler::convertCbMsgToMsginfo(SMS_CBMSG_S *pCbMsg, MSG_MESSA } -void SmsPluginCbMsgHandler::convertEtwsMsgToMsginfo(SMS_CBMSG_PAGE_S EtwsMsg, MSG_MESSAGE_INFO_S *pMsgInfo, msg_sim_slot_id_t simIndex) +void SmsPluginCbMsgHandler::convertEtwsMsgToMsginfo(SMS_CBMSG_PAGE_S *EtwsMsg, MSG_MESSAGE_INFO_S *pMsgInfo, msg_sim_slot_id_t simIndex) { - pMsgInfo->msgId = (msg_message_id_t)EtwsMsg.pageHeader.msgId; + pMsgInfo->msgId = (msg_message_id_t)EtwsMsg->pageHeader.msgId; pMsgInfo->folderId = MSG_CBMSGBOX_ID; // Convert Type values pMsgInfo->msgType.mainType = MSG_SMS_TYPE; - if (EtwsMsg.cbMsgType == SMS_CBMSG_TYPE_ETWS) + if (EtwsMsg->cbMsgType == SMS_CBMSG_TYPE_ETWS) pMsgInfo->msgType.subType = MSG_ETWS_SMS; pMsgInfo->storageId = MSG_STORAGE_PHONE; @@ -897,20 +899,20 @@ void SmsPluginCbMsgHandler::convertEtwsMsgToMsginfo(SMS_CBMSG_PAGE_S EtwsMsg, MS pMsgInfo->addressList[0].addressType = MSG_ADDRESS_TYPE_UNKNOWN; pMsgInfo->addressList[0].recipientType = MSG_RECIPIENTS_TYPE_UNKNOWN; - getDisplayName(EtwsMsg.pageHeader.msgId, pMsgInfo->addressList[0].addressVal, simIndex); + getDisplayName(EtwsMsg->pageHeader.msgId, pMsgInfo->addressList[0].addressVal, simIndex); MSG_SEC_DEBUG("%s", pMsgInfo->addressList[0].addressVal); pMsgInfo->msgPort.valid = false; pMsgInfo->msgPort.dstPort = 0; pMsgInfo->msgPort.srcPort = 0; - pMsgInfo->displayTime = EtwsMsg.pageHeader.recvTime; - MSG_DEBUG("recvTime is %s", ctime(&pMsgInfo->displayTime)); - MSG_DEBUG("LENGTH %d", EtwsMsg.pageLength); + pMsgInfo->displayTime = EtwsMsg->pageHeader.recvTime; + MSG_DEBUG("recvTime is %d", pMsgInfo->displayTime); + MSG_DEBUG("LENGTH %d", EtwsMsg->pageLength); pMsgInfo->bTextSms = true; - pMsgInfo->dataSize = EtwsMsg.pageLength; + pMsgInfo->dataSize = EtwsMsg->pageLength; memset(pMsgInfo->msgData, 0x00, sizeof(pMsgInfo->msgData)); - memcpy(pMsgInfo->msgData, EtwsMsg.pageData, pMsgInfo->dataSize); + memcpy(pMsgInfo->msgData, EtwsMsg->pageData, pMsgInfo->dataSize); } int SmsPluginCbMsgHandler::convertTextToUtf8 (unsigned char* outBuf, int outBufSize, SMS_CBMSG_S* pCbMsg) @@ -939,40 +941,40 @@ int SmsPluginCbMsgHandler::convertTextToUtf8 (unsigned char* outBuf, int outBufS return convertedTextSize; } -void SmsPluginCbMsgHandler::addToPageList(SMS_CBMSG_PAGE_S CbPage) +void SmsPluginCbMsgHandler::addToPageList(SMS_CBMSG_PAGE_S *CbPage) { CB_PAGE_INFO_S tmpInfo; - tmpInfo.geoScope = CbPage.pageHeader.serialNum.geoScope; - tmpInfo.msgCode = CbPage.pageHeader.serialNum.msgCode; - tmpInfo.updateNum = CbPage.pageHeader.serialNum.updateNum; - tmpInfo.msgId = CbPage.pageHeader.msgId; - tmpInfo.totalPages = CbPage.pageHeader.totalPages; + tmpInfo.geoScope = CbPage->pageHeader.serialNum.geoScope; + tmpInfo.msgCode = CbPage->pageHeader.serialNum.msgCode; + tmpInfo.updateNum = CbPage->pageHeader.serialNum.updateNum; + tmpInfo.msgId = CbPage->pageHeader.msgId; + tmpInfo.totalPages = CbPage->pageHeader.totalPages; tmpInfo.pageCnt = 1; - tmpInfo.totalSize = CbPage.pageLength; + tmpInfo.totalSize = CbPage->pageLength; - pair<unsigned char, SMS_CBMSG_PAGE_S> newData(CbPage.pageHeader.page, CbPage); + pair<unsigned char, SMS_CBMSG_PAGE_S> newData(CbPage->pageHeader.page, *CbPage); tmpInfo.data.insert(newData); - MSG_DEBUG("MSG DATA : %s", CbPage.pageData); + MSG_DEBUG("MSG DATA : %s", CbPage->pageData); MSG_DEBUG("PAIR DATA [%d] : %s", newData.first, newData.second.pageData); pageList.push_back(tmpInfo); } -void SmsPluginCbMsgHandler::removeFromPageList(SMS_CBMSG_PAGE_S CbPage) +void SmsPluginCbMsgHandler::removeFromPageList(SMS_CBMSG_PAGE_S *CbPage) { unsigned int index; for (index = 0; index < pageList.size(); index++) { - if (pageList[index].geoScope == CbPage.pageHeader.serialNum.geoScope && pageList[index].msgCode == CbPage.pageHeader.serialNum.msgCode) + if (pageList[index].geoScope == CbPage->pageHeader.serialNum.geoScope && pageList[index].msgCode == CbPage->pageHeader.serialNum.msgCode) { MSG_DEBUG("geoScope [%d], msgCode [%d]", pageList[index].geoScope, pageList[index].msgCode); - if (pageList[index].msgId == CbPage.pageHeader.msgId) break; + if (pageList[index].msgId == CbPage->pageHeader.msgId) break; } } @@ -1186,6 +1188,6 @@ void SmsPluginCbMsgHandler::getDisplayName(unsigned short MsgId, char *pDisplayN } } - sprintf(pDisplayName, "[%d]", MsgId); + snprintf(pDisplayName, MAX_ADDRESS_VAL_LEN + 1, "[%d]", MsgId); } diff --git a/plugin/sms_plugin/SmsPluginConcatHandler.cpp b/plugin/sms_plugin/SmsPluginConcatHandler.cpp index 9d05c55..07101ac 100755 --- a/plugin/sms_plugin/SmsPluginConcatHandler.cpp +++ b/plugin/sms_plugin/SmsPluginConcatHandler.cpp @@ -145,12 +145,12 @@ void SmsPluginConcatHandler::handleConcatMsg(struct tapi_handle *handle, SMS_TPD int dataSize = 0; char* pUserData = NULL; bool simSlotSizeOver = false; - AutoPtr<char> dataBuf(&pUserData); + unique_ptr<char*, void(*)(char**)> dataBuf(&pUserData, unique_ptr_deleter); MSG_MESSAGE_INFO_S msgInfo = {0}; msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); msgInfo.sim_idx = msg.simIndex; dataSize = makeConcatUserData(msg.msgRef, msg.simIndex, &pUserData); @@ -189,7 +189,7 @@ void SmsPluginConcatHandler::handleConcatMsg(struct tapi_handle *handle, SMS_TPD (SmsPluginSimMsg::instance()->checkSimMsgFull(msg.simIndex, segCnt) == true)) { char keyName[MAX_VCONFKEY_NAME_LEN]; memset(keyName, 0x00, sizeof(keyName)); - sprintf(keyName, "%s/%d", SIM_TOTAL_COUNT, msg.simIndex); + snprintf(keyName, sizeof(keyName), "%s/%d", SIM_TOTAL_COUNT, msg.simIndex); int totalCnt = MsgSettingGetInt(keyName); if (segCnt > totalCnt) { @@ -285,12 +285,12 @@ void SmsPluginConcatHandler::handleSimConcatMsg(struct tapi_handle *handle, SMS_ int dataSize = 0; char* pUserData = NULL; - AutoPtr<char> dataBuf(&pUserData); + unique_ptr<char*, void(*)(char**)> dataBuf(&pUserData, unique_ptr_deleter); MSG_MESSAGE_INFO_S msgInfo = {0}; msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); msgInfo.sim_idx = msg.simIndex; dataSize = makeConcatUserData(msg.msgRef, msg.simIndex, &pUserData); @@ -365,12 +365,12 @@ void SmsPluginConcatHandler::handleSimConcatMsg(struct tapi_handle *handle, SMS_ int dataSize = 0; char* pUserData = NULL; - AutoPtr<char> dataBuf(&pUserData); + unique_ptr<char*, void(*)(char**)> dataBuf(&pUserData, unique_ptr_deleter); MSG_MESSAGE_INFO_S msgInfo = {0}; msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); msgInfo.sim_idx = msg.simIndex; dataSize = makeConcatUserData(msg.msgRef, msg.simIndex, &pUserData); @@ -472,7 +472,7 @@ void SmsPluginConcatHandler::handleConcatMsg(SMS_TPDU_S *pTpdu, msg_sim_id_t Sim int dataSize = 0; char* pUserData = NULL; - AutoPtr<char> dataBuf(&pUserData); + unique_ptr<char*, void(*)(char**)> dataBuf(&pUserData, unique_ptr_deleter); MSG_MESSAGE_INFO_S msgInfo = {0}; @@ -551,7 +551,7 @@ void SmsPluginConcatHandler::handleBrokenMsg() { int index = 0, dataSize = 0; char* pUserData = NULL; - AutoPtr<char> dataBuf(&pUserData); + unique_ptr<char*, void(*)(char**)> dataBuf(&pUserData, unique_ptr_deleter); MSG_MESSAGE_INFO_S msgInfo = {0}; @@ -706,7 +706,8 @@ int SmsPluginConcatHandler::makeConcatUserData(unsigned short MsgRef, int simInd MSG_DEBUG("totalSize [%d]", totalSize); - *ppTotalData = new char[totalSize]; + if (*ppTotalData == NULL) + *ppTotalData = new char[totalSize]; for (it = concatList[i].data.begin(); it != concatList[i].data.end(); it++) { memcpy(*ppTotalData+offset, it->second.data, it->second.length); diff --git a/plugin/sms_plugin/SmsPluginDSHandler.cpp b/plugin/sms_plugin/SmsPluginDSHandler.cpp index 5339c13..64939ff 100755 --- a/plugin/sms_plugin/SmsPluginDSHandler.cpp +++ b/plugin/sms_plugin/SmsPluginDSHandler.cpp @@ -26,10 +26,8 @@ extern "C" #include <TelNetwork.h> #include <ITapiNetwork.h> #include <ITapiSim.h> -#if 0 #include <telephony_common.h> #include <telephony_sim.h> -#endif } /*================================================================================================== @@ -40,6 +38,8 @@ SmsPluginDSHandler* SmsPluginDSHandler::pInstance = NULL; SmsPluginDSHandler::SmsPluginDSHandler() { + cp_list = NULL; + memset(&handle_list, 0x00, sizeof(handle_list)); } @@ -130,7 +130,7 @@ int SmsPluginDSHandler::getSimIndex(struct tapi_handle *handle) void SmsPluginDSHandler::getDefaultNetworkSimId(int *simId) { - TelNetworkDefaultDataSubs_t defaultSimId; + TelNetworkDefaultDataSubs_t defaultSimId = TAPI_NETWORK_DEFAULT_DATA_SUBS_UNKNOWN; int tapi_ret = TAPI_API_SUCCESS; @@ -182,7 +182,6 @@ int SmsPluginDSHandler::getActiveSimCount() int SmsPluginDSHandler::getSubscriberId(unsigned int simIndex, char **subscriber_id) { -#if 0 if (simIndex <= 0 || simIndex > (unsigned int)handle_list.count) { MSG_DEBUG("Invalid SIM index"); return MSG_ERR_INVALID_PARAMETER; @@ -209,6 +208,5 @@ int SmsPluginDSHandler::getSubscriberId(unsigned int simIndex, char **subscriber MSG_DEBUG("Deinitialize failed!!!"); } -#endif return MSG_SUCCESS; } diff --git a/plugin/sms_plugin/SmsPluginEventHandler.cpp b/plugin/sms_plugin/SmsPluginEventHandler.cpp index 46956d8..7416749 100755 --- a/plugin/sms_plugin/SmsPluginEventHandler.cpp +++ b/plugin/sms_plugin/SmsPluginEventHandler.cpp @@ -14,9 +14,9 @@ * limitations under the License. */ -#include<time.h> -#include<stdio.h> -#include<stdlib.h> +#include <time.h> +#include <stdio.h> +#include <stdlib.h> #include <errno.h> #include "MsgDebug.h" @@ -45,6 +45,7 @@ SmsPluginEventHandler::SmsPluginEventHandler() { /** Initialize global parameters */ memset(&listener, 0x00, sizeof(MSG_PLUGIN_LISTENER_S)); + memset(&sentInfo, 0x00, sizeof(SMS_SENT_INFO_S)); pSimCnt = NULL; devStatus = false; @@ -132,7 +133,7 @@ void SmsPluginEventHandler::handleMsgIncoming(struct tapi_handle *handle, SMS_TP memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); if (pTpdu->tpduType == SMS_TPDU_DELIVER) { @@ -251,7 +252,7 @@ void SmsPluginEventHandler::handleMsgIncoming(struct tapi_handle *handle, SMS_TP MSG_DEBUG("msgInfo.msgType.mainType : %d", msgInfo.msgType.mainType); MSG_DEBUG("msgInfo.msgType.subType : %d", msgInfo.msgType.subType); MSG_DEBUG("msgInfo.msgType.classType : %d", msgInfo.msgType.classType); - MSG_DEBUG("msgInfo.displayTime : %s", ctime(&msgInfo.displayTime)); + MSG_DEBUG("msgInfo.displayTime : %d", msgInfo.displayTime); MSG_DEBUG("msgInfo.msgPort.valid : %d", msgInfo.msgPort.valid); MSG_DEBUG("msgInfo.encodeType : %d", msgInfo.encodeType); MSG_DEBUG("msgInfo.dataSize : %d", msgInfo.dataSize); @@ -512,15 +513,15 @@ void SmsPluginEventHandler::convertSubmitTpduToMsginfo(const SMS_SUBMIT_S *pTpdu /** What kind of time has to be saved?? (temporary store time) */ - time_t curTime; - localtime(&curTime); - - msgInfo->displayTime = curTime; +//CID 315780 (#1 of 1): Other violation (DC.SECURE_CODING_CRITICAL) +//dont_call: Calling localtime(time_t const *) is a DC.SECURE_CODING_CRITICAL defect. +// time_t curTime; +// localtime(&curTime); /** Convert Address values */ msgInfo->nAddressCnt = 1; - msgInfo->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)]; + msgInfo->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)]; memset(msgInfo->addressList, 0x00, sizeof(MSG_ADDRESS_INFO_S)); msgInfo->addressList[addressListCnt].addressType = MSG_ADDRESS_TYPE_PLMN; @@ -528,7 +529,7 @@ void SmsPluginEventHandler::convertSubmitTpduToMsginfo(const SMS_SUBMIT_S *pTpdu /**exception operation for none userdata */ if (pTpdu->userData.length == 0) { - sprintf(msgInfo->msgText, "[Broken Message]"); + snprintf(msgInfo->msgText, sizeof(msgInfo->msgText), "[Broken Message]"); msgInfo->dataSize = strlen(msgInfo->msgText); return; } @@ -575,7 +576,7 @@ void SmsPluginEventHandler::convertDeliverTpduToMsginfo(const SMS_DELIVER_S *pTp MSG_DEBUG("timezone : %d", pTpdu->timeStamp.time.absolute.timeZone); char displayTime[32]; - struct tm * timeTM; + struct tm timeTM; struct tm timeinfo; memset(&timeinfo, 0x00, sizeof(tm)); @@ -601,16 +602,16 @@ void SmsPluginEventHandler::convertDeliverTpduToMsginfo(const SMS_DELIVER_S *pTp rawtime -= (pTpdu->timeStamp.time.absolute.timeZone * (3600/4)); - timeTM = localtime(&rawtime); + localtime_r(&rawtime, &timeTM); memset(displayTime, 0x00, sizeof(displayTime)); - strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM); + strftime(displayTime, 32, "%Y-%02m-%02d %T %z", &timeTM); MSG_DEBUG("displayTime [%s]", displayTime); rawtime -= timezone; - timeTM = localtime(&rawtime); + localtime_r(&rawtime, &timeTM); memset(displayTime, 0x00, sizeof(displayTime)); - strftime(displayTime, 32, "%Y-%02m-%02d %T %z", timeTM); + strftime(displayTime, 32, "%Y-%02m-%02d %T %z", &timeTM); MSG_DEBUG("displayTime [%s]", displayTime); } } @@ -748,7 +749,7 @@ void SmsPluginEventHandler::convertDeliverTpduToMsginfo(const SMS_DELIVER_S *pTp return; } else if (pTpdu->userData.length > MAX_MSG_TEXT_LEN) { - sprintf(msgInfo->msgText, "[Broken Message]"); + snprintf(msgInfo->msgText, sizeof(msgInfo->msgText), "[Broken Message]"); msgInfo->dataSize = strlen(msgInfo->msgData); return; } diff --git a/plugin/sms_plugin/SmsPluginMain.cpp b/plugin/sms_plugin/SmsPluginMain.cpp index 05cf72c..6cd6d0d 100755 --- a/plugin/sms_plugin/SmsPluginMain.cpp +++ b/plugin/sms_plugin/SmsPluginMain.cpp @@ -219,7 +219,7 @@ msg_error_t SmsPlgSubmitRequest(MSG_REQUEST_INFO_S *pReqInfo) // Check SIM is present or not char keyName[MAX_VCONFKEY_NAME_LEN] = {0,}; - sprintf(keyName, "%s/%d", MSG_SIM_CHANGED, pReqInfo->msgInfo.sim_idx); + snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, pReqInfo->msgInfo.sim_idx); MSG_SIM_STATUS_T simStatus = (MSG_SIM_STATUS_T)MsgSettingGetInt(keyName); if (simStatus == MSG_SIM_STATUS_NOT_FOUND) @@ -292,7 +292,7 @@ msg_error_t SmsPlgDeleteSimMessage(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMs { // Check SIM is present or not char keyName[MAX_VCONFKEY_NAME_LEN]={0,}; - sprintf(keyName, "%s/%d", MSG_SIM_CHANGED, sim_idx); + snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, sim_idx); MSG_SIM_STATUS_T simStatus = (MSG_SIM_STATUS_T)MsgSettingGetInt(keyName); if (simStatus == MSG_SIM_STATUS_NOT_FOUND) { @@ -323,7 +323,7 @@ msg_error_t SmsPlgSetReadStatus(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMsgId { // Check SIM is present or not char keyName[MAX_VCONFKEY_NAME_LEN]={0,}; - sprintf(keyName, "%s/%d", MSG_SIM_CHANGED, sim_idx); + snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, sim_idx); MSG_SIM_STATUS_T simStatus = (MSG_SIM_STATUS_T)MsgSettingGetInt(keyName); if (simStatus == MSG_SIM_STATUS_NOT_FOUND) { diff --git a/plugin/sms_plugin/SmsPluginSatHandler.cpp b/plugin/sms_plugin/SmsPluginSatHandler.cpp index ab75e1a..1ca9df7 100755 --- a/plugin/sms_plugin/SmsPluginSatHandler.cpp +++ b/plugin/sms_plugin/SmsPluginSatHandler.cpp @@ -550,7 +550,7 @@ int SmsPluginSatHandler::handleSatTpdu(unsigned char *pTpdu, unsigned char TpduL dcs.codingScheme = SMS_CHARSET_7BIT; char* pDcs = NULL; - AutoPtr<char> dcsBuf(&pDcs); + unique_ptr<char*, void(*)(char**)> dcsBuf(&pDcs, unique_ptr_deleter); SmsPluginParamCodec::encodeDCS(&dcs, &pDcs); diff --git a/plugin/sms_plugin/SmsPluginSetting.cpp b/plugin/sms_plugin/SmsPluginSetting.cpp index 32bf2d5..cf88ba7 100755 --- a/plugin/sms_plugin/SmsPluginSetting.cpp +++ b/plugin/sms_plugin/SmsPluginSetting.cpp @@ -73,6 +73,7 @@ SmsPluginSetting::SmsPluginSetting() bTapiResult = false; paramCnt = 0; selectedParam = 0; + selectedSimIndex = 0; for (int i = 0; i < MAX_TELEPHONY_HANDLE_CNT; i++) bMbdnEnable[i] = false; @@ -142,8 +143,6 @@ void SmsPluginSetting::updateSimStatus(struct tapi_handle *handle) tapiRet = tel_get_sim_imsi(handle, &imsiInfo); if (tapiRet != TAPI_API_SUCCESS) { MSG_DEBUG("tel_get_sim_imsi() Error![%d]", tapiRet); - snprintf(keyName, sizeof(keyName), "%s/%d", MSG_NATIONAL_SIM, simIndex); - MsgSettingSetBool(keyName, false); } /* Save Subcriber ID */ @@ -154,7 +153,8 @@ void SmsPluginSetting::updateSimStatus(struct tapi_handle *handle) MSG_DEBUG("getSubscriberId() is failed"); } else { snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_SUBS_ID, simIndex); - MsgSettingSetString(keyName, subscriberId); + if (MsgSettingSetString(keyName, subscriberId) != MSG_SUCCESS) + MSG_DEBUG("Fail MsgSettingSetString"); } g_free(subscriberId); subscriberId = NULL; @@ -886,7 +886,7 @@ bool SmsPluginSetting::setCbConfig(const MSG_CBMSG_OPT_S *pCbOpt) err = MsgStoAddCBChannelInfo(dbHandle, const_cast<MSG_CB_CHANNEL_S*>(&pCbOpt->channelData),i); if (err != MSG_SUCCESS) { MSG_DEBUG("MsgStoAddCBChannelInfo is failed [%d]", err); - return MSG_ERR_SET_SETTING; + return false; } } @@ -1728,7 +1728,7 @@ void SmsPluginSetting::deliverVoiceMsgNoti(int simIndex, int mwiCnt) MSG_MESSAGE_INFO_S msgInfo = {0,}; msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); msgInfo.addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)]; memset(msgInfo.addressList, 0x00, sizeof(MSG_ADDRESS_INFO_S)); diff --git a/plugin/sms_plugin/SmsPluginSimMsg.cpp b/plugin/sms_plugin/SmsPluginSimMsg.cpp index 6ba9ac3..4a73e7b 100755 --- a/plugin/sms_plugin/SmsPluginSimMsg.cpp +++ b/plugin/sms_plugin/SmsPluginSimMsg.cpp @@ -49,6 +49,9 @@ SmsPluginSimMsg::SmsPluginSimMsg() bTapiResult = false; memset(&simMsgDataInfo, 0x00, sizeof(simMsgDataInfo)); memset(simIdList, 0, sizeof(int) * MAX_SIM_SMS_NUM); + memset(&simMsgCnt, 0x00, sizeof(simMsgCnt)); + memset(&simMsgInfo, 0x00, sizeof(simMsgInfo)); + memset(&simAddrInfo, 0x00, sizeof(simAddrInfo)); } @@ -297,7 +300,7 @@ msg_error_t SmsPluginSimMsg::saveSimMessage(const MSG_MESSAGE_INFO_S *pMsgInfo, char keyName[MAX_VCONFKEY_NAME_LEN]; memset(keyName, 0x00, sizeof(keyName)); - sprintf(keyName, "%s/%d", SIM_USED_COUNT, pMsgInfo->sim_idx); + snprintf(keyName, sizeof(keyName), "%s/%d", SIM_USED_COUNT, pMsgInfo->sim_idx); usedCnt = MsgSettingGetInt(keyName); usedCnt++; @@ -442,26 +445,27 @@ msg_error_t SmsPluginSimMsg::saveClass2Message(const MSG_MESSAGE_INFO_S *pMsgInf simSmsData.MsgStatus = TAPI_NETTEXT_STATUS_UNREAD; MSG_MESSAGE_INFO_S *tmpSimMsgInfo = (MSG_MESSAGE_INFO_S *)calloc(1, sizeof(MSG_MESSAGE_INFO_S)); - memcpy(tmpSimMsgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S)); + if (tmpSimMsgInfo) { + memcpy(tmpSimMsgInfo, pMsgInfo, sizeof(MSG_MESSAGE_INFO_S)); - tmpSimMsgInfo->msgId = replaceMsgId; + tmpSimMsgInfo->msgId = replaceMsgId; - tmpSimMsgInfo->addressList = NULL; - tmpSimMsgInfo->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)]; - memcpy(&tmpSimMsgInfo->addressList[0], &pMsgInfo->addressList[0], sizeof(MSG_ADDRESS_INFO_S)); + tmpSimMsgInfo->addressList = NULL; + tmpSimMsgInfo->addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)]; + memcpy(&tmpSimMsgInfo->addressList[0], &pMsgInfo->addressList[0], sizeof(MSG_ADDRESS_INFO_S)); - tapiRet = tel_write_sms_in_sim(handle, &simSmsData, TapiEventSaveClass2Msg, tmpSimMsgInfo); + tapiRet = tel_write_sms_in_sim(handle, &simSmsData, TapiEventSaveClass2Msg, tmpSimMsgInfo); - if (tapiRet == TAPI_API_SUCCESS) { - MSG_DEBUG("######## tel_write_sms_in_sim Success !!!, segNum = [%d] #######", segCnt); - } else { - MSG_DEBUG("######## tel_write_sms_in_sim Fail !!! return : [%d] #######", tapiRet); + if (tapiRet == TAPI_API_SUCCESS) { + MSG_DEBUG("######## tel_write_sms_in_sim Success !!!, segNum = [%d] #######", segCnt); + } else { + MSG_DEBUG("######## tel_write_sms_in_sim Fail !!! return : [%d] #######", tapiRet); - SmsPluginTransport::instance()->sendDeliverReport(handle, MSG_ERR_STORAGE_ERROR); + SmsPluginTransport::instance()->sendDeliverReport(handle, MSG_ERR_STORAGE_ERROR); - return MSG_ERR_PLUGIN_STORAGE; + return MSG_ERR_PLUGIN_STORAGE; + } } - msg_sim_id_t retSimId; if (!getSimEvent(&retSimId)) return MSG_ERR_PLUGIN_STORAGE; @@ -499,10 +503,10 @@ void SmsPluginSimMsg::deleteSimMessage(msg_sim_slot_id_t sim_idx, msg_sim_id_t S MSG_DEBUG("######## Deleting Msg was Successful !!! SIM ID : [%d] #######", SimId); char keyName[MAX_VCONFKEY_NAME_LEN]; memset(keyName, 0x00, sizeof(keyName)); - sprintf(keyName, "%s/%d", SIM_USED_COUNT, sim_idx); + snprintf(keyName, sizeof(keyName), "%s/%d", SIM_USED_COUNT, sim_idx); usedCnt = MsgSettingGetInt(keyName); memset(keyName, 0x00, sizeof(keyName)); - sprintf(keyName, "%s/%d", SIM_TOTAL_COUNT, sim_idx); + snprintf(keyName, sizeof(keyName), "%s/%d", SIM_TOTAL_COUNT, sim_idx); totalCnt = MsgSettingGetInt(keyName); if (usedCnt == totalCnt) @@ -522,7 +526,7 @@ void SmsPluginSimMsg::deleteSimMessage(msg_sim_slot_id_t sim_idx, msg_sim_id_t S usedCnt--; memset(keyName, 0x00, sizeof(keyName)); - sprintf(keyName, "%s/%d", SIM_USED_COUNT, sim_idx); + snprintf(keyName, sizeof(keyName), "%s/%d", SIM_USED_COUNT, sim_idx); if (MsgSettingSetInt(keyName, usedCnt) != MSG_SUCCESS) { @@ -542,10 +546,10 @@ bool SmsPluginSimMsg::checkSimMsgFull(msg_sim_slot_id_t sim_idx, unsigned int Se char keyName[MAX_VCONFKEY_NAME_LEN]; memset(keyName, 0x00, sizeof(keyName)); - sprintf(keyName, "%s/%d", SIM_USED_COUNT, sim_idx); + snprintf(keyName, sizeof(keyName), "%s/%d", SIM_USED_COUNT, sim_idx); usedCnt = MsgSettingGetInt(keyName); memset(keyName, 0x00, sizeof(keyName)); - sprintf(keyName, "%s/%d", SIM_TOTAL_COUNT, sim_idx); + snprintf(keyName, sizeof(keyName), "%s/%d", SIM_TOTAL_COUNT, sim_idx); totalCnt = MsgSettingGetInt(keyName); MSG_DEBUG("Segment Count [%d]", SegCnt); @@ -908,7 +912,8 @@ void SmsPluginSimMsg::setSaveClass2MsgEvent(struct tapi_handle *handle, int simI if (isNewSimMsg == true) { char keyName[MAX_VCONFKEY_NAME_LEN]; - sprintf(keyName, "%s/%d", SIM_USED_COUNT, pMsgInfo->sim_idx); + memset(keyName, 0x00, sizeof(keyName)); + snprintf(keyName, sizeof(keyName), "%s/%d", SIM_USED_COUNT, pMsgInfo->sim_idx); usedCnt = MsgSettingGetInt(keyName); usedCnt++; diff --git a/plugin/sms_plugin/SmsPluginStorage.cpp b/plugin/sms_plugin/SmsPluginStorage.cpp index 33eafa4..5f42011 100755 --- a/plugin/sms_plugin/SmsPluginStorage.cpp +++ b/plugin/sms_plugin/SmsPluginStorage.cpp @@ -38,11 +38,8 @@ SmsPluginStorage* SmsPluginStorage::pInstance = NULL; SmsPluginStorage::SmsPluginStorage() { -/*** No need to connect DB anymore. - if (dbHandle->connect() != MSG_SUCCESS) { - MSG_DEBUG("DB Connect Fail"); - } -***/ + memset(&msgInfo, 0x00, sizeof(msgInfo)); + memset(&addrInfo, 0x00, sizeof(addrInfo)); } @@ -130,7 +127,7 @@ msg_error_t SmsPluginStorage::updateMsgDeliverStatus(MSG_MESSAGE_INFO_S *pMsgInf snprintf(sqlQuery, sizeof(sqlQuery), "SELECT * FROM %s WHERE MSG_ID = %d AND MSG_REF > 0;", MSGFW_SMS_REPORT_TABLE_NAME, msgId); - if (dbHandle->getTable(sqlQuery, &rowCnt) != MSG_SUCCESS) { + if (dbHandle->getTable(sqlQuery, &rowCnt, NULL) != MSG_SUCCESS) { dbHandle->freeTable(); return MSG_ERR_DB_GETTABLE; } @@ -768,7 +765,7 @@ void* SmsPluginStorage::class2_thread(void *data) } MSG_END(); - return NULL; + return (void *)err; } @@ -940,7 +937,7 @@ msg_error_t SmsPluginStorage::isReceivedCBMessage(SMS_CBMSG_PAGE_S CbPage) MSGFW_RECEIVED_CB_MSG_TABLE_NAME, CbPage.pageHeader.serialNum.geoScope, CbPage.pageHeader.serialNum.msgCode,CbPage.pageHeader.msgId, CbPage.pageHeader.serialNum.updateNum); - err = dbHandle->getTable(sqlQuery, &rowCnt); + err = dbHandle->getTable(sqlQuery, &rowCnt, NULL); MSG_DEBUG("rowCnt: %d", rowCnt); dbHandle->freeTable(); @@ -982,7 +979,7 @@ msg_error_t SmsPluginStorage::getRegisteredPushEvent(char* pPushHeader, int *cou { msg_error_t err = MSG_SUCCESS; - int rowCnt = 0, index = 3; + int rowCnt = 0, index = 0; MsgDbHandler *dbHandle = getDbHandle(); @@ -992,7 +989,7 @@ msg_error_t SmsPluginStorage::getRegisteredPushEvent(char* pPushHeader, int *cou snprintf(sqlQuery, sizeof(sqlQuery), "SELECT CONTENT_TYPE, APP_ID, APPCODE FROM %s", MSGFW_PUSH_CONFIG_TABLE_NAME); - err = dbHandle->getTable(sqlQuery, &rowCnt); + err = dbHandle->getTable(sqlQuery, &rowCnt, &index); MSG_DEBUG("rowCnt: %d", rowCnt); if (err == MSG_ERR_DB_NORECORD) { diff --git a/plugin/sms_plugin/SmsPluginTpduCodec.cpp b/plugin/sms_plugin/SmsPluginTpduCodec.cpp index 2b17797..789f14b 100755 --- a/plugin/sms_plugin/SmsPluginTpduCodec.cpp +++ b/plugin/sms_plugin/SmsPluginTpduCodec.cpp @@ -104,13 +104,13 @@ int SmsPluginTpduCodec::encodeSubmit(const SMS_SUBMIT_S *pSubmit, char *pTpdu) int offset = 0, length = 0, encodeSize = 0; char* address = NULL; - AutoPtr<char> addressBuf(&address); + unique_ptr<char*, void(*)(char**)> addressBuf(&address, unique_ptr_deleter); char* dcs = NULL; - AutoPtr<char> dcsBuf(&dcs); + unique_ptr<char*, void(*)(char**)> dcsBuf(&dcs, unique_ptr_deleter); char* vpTime = NULL; - AutoPtr<char> vpBuf(&vpTime); + unique_ptr<char*, void(*)(char**)> vpBuf(&vpTime, unique_ptr_deleter); //TP-MTI pTpdu[offset] = 0x01; @@ -213,13 +213,13 @@ int SmsPluginTpduCodec::encodeDeliver(const SMS_DELIVER_S *pDeliver, char *pTpdu int offset = 0, length = 0, encodeSize = 0; char* address = NULL; - AutoPtr<char> addressBuf(&address); + unique_ptr<char*, void(*)(char**)> addressBuf(&address, unique_ptr_deleter); char* dcs = NULL; - AutoPtr<char> dcsBuf(&dcs); + unique_ptr<char*, void(*)(char**)> dcsBuf(&dcs, unique_ptr_deleter); char* scts = NULL; - AutoPtr<char> timeBuf(&scts); + unique_ptr<char*, void(*)(char**)> timeBuf(&scts, unique_ptr_deleter); // TP-MTI : 00 pTpdu[offset] = 0x00; @@ -303,7 +303,7 @@ int SmsPluginTpduCodec::encodeDeliverReport(const SMS_DELIVER_REPORT_S *pDeliver int length = 0; char* dcs = NULL; - AutoPtr<char> dcsBuf(&dcs); + unique_ptr<char*, void(*)(char**)> dcsBuf(&dcs, unique_ptr_deleter); length = SmsPluginParamCodec::encodeDCS(&pDeliverRep->dcs, &dcs); memcpy(&(pTpdu[offset]), dcs, length); @@ -334,13 +334,13 @@ int SmsPluginTpduCodec::encodeStatusReport(const SMS_STATUS_REPORT_S *pStatusRep int offset = 0, length = 0; char* address = NULL; - AutoPtr<char> addressBuf(&address); + unique_ptr<char*, void(*)(char**)> addressBuf(&address, unique_ptr_deleter); char* scts = NULL; - AutoPtr<char> sctsBuf(&scts); + unique_ptr<char*, void(*)(char**)> sctsBuf(&scts, unique_ptr_deleter); char* dt = NULL; - AutoPtr<char> dtBuf(&dt); + unique_ptr<char*, void(*)(char**)> dtBuf(&dt, unique_ptr_deleter); // TP-MTI : 10 pTpdu[offset] = 0x02; @@ -393,7 +393,7 @@ int SmsPluginTpduCodec::encodeStatusReport(const SMS_STATUS_REPORT_S *pStatusRep int length = 0; char* dcs = NULL; - AutoPtr<char> dcsBuf(&dcs); + unique_ptr<char*, void(*)(char**)> dcsBuf(&dcs, unique_ptr_deleter); length = SmsPluginParamCodec::encodeDCS(&pStatusRep->dcs, &dcs); memcpy(&(pTpdu[offset]), dcs, length); @@ -612,13 +612,13 @@ int SmsPluginTpduCodec::decodeStatusReport(const unsigned char *pTpdu, int TpduL int offset = 0, udLen = 0; char* address = NULL; - AutoPtr<char> addressBuf(&address); + unique_ptr<char*, void(*)(char**)> addressBuf(&address, unique_ptr_deleter); char* scts = NULL; - AutoPtr<char> sctsBuf(&scts); + unique_ptr<char*, void(*)(char**)> sctsBuf(&scts, unique_ptr_deleter); char* dt = NULL; - AutoPtr<char> dtBuf(&dt); + unique_ptr<char*, void(*)(char**)> dtBuf(&dt, unique_ptr_deleter); // TP-MMS if (pTpdu[offset] & 0x04) diff --git a/plugin/sms_plugin/SmsPluginTransport.cpp b/plugin/sms_plugin/SmsPluginTransport.cpp index 2a9b236..37d0675 100755 --- a/plugin/sms_plugin/SmsPluginTransport.cpp +++ b/plugin/sms_plugin/SmsPluginTransport.cpp @@ -53,6 +53,7 @@ SmsPluginTransport::SmsPluginTransport() msgRef = 0x00; msgRef8bit = 0x00; msgRef16bit = 0x0000; + curStatus = 0x00; memset(&curMoCtrlData, 0x00, sizeof(curMoCtrlData)); } @@ -104,7 +105,7 @@ void SmsPluginTransport::submitRequest(SMS_REQUEST_INFO_S *pReqInfo) //contacts-service is not used for gear #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED MsgStoGetAddressByMsgId(dbHandle, pReqInfo->msgInfo.msgId, 0, &pReqInfo->msgInfo.nAddressCnt, &pReqInfo->msgInfo.addressList); -#else +#else // MSG_CONTACTS_SERVICE_NOT_SUPPORTED //contactNameOrder is never used MsgStoGetAddressByMsgId(dbHandle, pReqInfo->msgInfo.msgId, &pReqInfo->msgInfo.nAddressCnt, &pReqInfo->msgInfo.addressList); #endif //MSG_CONTACTS_SERVICE_NOT_SUPPORTED @@ -861,7 +862,7 @@ void SmsPluginTransport::msgInfoToSubmitData(const MSG_MESSAGE_INFO_S *pMsgInfo, int fileSize = 0; char* pFileData = NULL; - AutoPtr<char> FileBuf(&pFileData); + unique_ptr<char*, void(*)(char**)> FileBuf(&pFileData, unique_ptr_deleter); // Read Message Data from File if (MsgOpenAndReadFile(pMsgInfo->msgData, &pFileData, &fileSize) == false) @@ -901,7 +902,7 @@ MSG_SEC_DEBUG("reply address : [%s]", pMsgInfo->replyAddress); int addrLen = 0; char* encodedAddr = NULL; - AutoPtr<char> addressBuf(&encodedAddr); + unique_ptr<char*, void(*)(char**)> addressBuf(&encodedAddr, unique_ptr_deleter); if (strlen(pMsgInfo->replyAddress) > 0) { @@ -922,6 +923,9 @@ MSG_SEC_DEBUG("reply address : [%s]", pMsgInfo->replyAddress); segSize = getSegmentSize(*pCharType, decodeLen, pMsgInfo->msgPort.valid, langId, addrLen); + if (segSize == 0) + THROW(MsgException::SMS_PLG_ERROR, "DIVIDE_BY_ZERO : %d", segSize); + pData->segCount = ceil((double)decodeLen/(double)segSize); MSG_DEBUG("segment size : [%d], pData->segCount : [%d]", segSize, pData->segCount); diff --git a/plugin/sms_plugin/SmsPluginUAManager.cpp b/plugin/sms_plugin/SmsPluginUAManager.cpp index b5b0892..fb72329 100755 --- a/plugin/sms_plugin/SmsPluginUAManager.cpp +++ b/plugin/sms_plugin/SmsPluginUAManager.cpp @@ -64,7 +64,7 @@ void SmsPluginUAManager::run() unlock(); request.msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&request.msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&request.msgInfo.addressList, unique_ptr_deleter); try { diff --git a/plugin/sms_plugin/SmsPluginUDCodec.cpp b/plugin/sms_plugin/SmsPluginUDCodec.cpp index 2b821be..d5b51e6 100755 --- a/plugin/sms_plugin/SmsPluginUDCodec.cpp +++ b/plugin/sms_plugin/SmsPluginUDCodec.cpp @@ -19,6 +19,7 @@ #include "SmsPluginParamCodec.h" #include "SmsPluginUDCodec.h" +using namespace std; /*================================================================================================== IMPLEMENTATION OF SmsPluginUDCodec - Member Functions @@ -519,7 +520,7 @@ int SmsPluginUDCodec::encodeHeader(const SMS_UDH_S header, char *pEncodeHeader) int offset = 0, addrLen = 0; char* encodedAddr = NULL; - AutoPtr<char> addressBuf(&encodedAddr); + unique_ptr<char*, void(*)(char**)> addressBuf(&encodedAddr, unique_ptr_deleter); switch (header.udhType) { diff --git a/plugin/sms_plugin/SmsPluginWapPushHandler.cpp b/plugin/sms_plugin/SmsPluginWapPushHandler.cpp index fb02f6e..58ac6ce 100755 --- a/plugin/sms_plugin/SmsPluginWapPushHandler.cpp +++ b/plugin/sms_plugin/SmsPluginWapPushHandler.cpp @@ -720,6 +720,7 @@ SmsPluginWapPushHandler* SmsPluginWapPushHandler::pInstance = NULL; SmsPluginWapPushHandler::SmsPluginWapPushHandler() { memset(&tmpAddress, 0x00, sizeof(tmpAddress)); + memset(&tmpTimeStamp, 0x00, sizeof(tmpTimeStamp)); } @@ -843,21 +844,21 @@ void SmsPluginWapPushHandler::handleWapPushMsg(const char *pUserData, int DataSi unsigned long PDUTypeDataLen = DataSize; char* pPushHeader = NULL; - AutoPtr<char> pushHeaderBuf(&pPushHeader); + unique_ptr<char*, void(*)(char**)> pushHeaderBuf(&pPushHeader, unique_ptr_deleter); unsigned long pushHeaderLen = 0; char* pPushBody = NULL; - AutoPtr<char> PushBodyBuf(&pPushBody); + unique_ptr<char*, void(*)(char**)> PushBodyBuf(&pPushBody, unique_ptr_deleter); unsigned long pushBodyLen = 0; unsigned long iPDU = 1; char* pWspHeader = NULL; - AutoPtr<char> WspHeaderBuf(&pWspHeader); + unique_ptr<char*, void(*)(char**)> WspHeaderBuf(&pWspHeader, unique_ptr_deleter); unsigned long wspHeaderLen = 0; char* pWspBody = NULL; - AutoPtr<char> WspBodyBuf(&pWspBody); + unique_ptr<char*, void(*)(char**)> WspBodyBuf(&pWspBody, unique_ptr_deleter); unsigned long wspBodyLen = 0; /** pass PDU type */ @@ -1423,7 +1424,7 @@ void SmsPluginWapPushHandler::handleMMSNotification(const char *pPushBody, int P memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); createMsgInfo(&msgInfo); @@ -1594,7 +1595,7 @@ void SmsPluginWapPushHandler::handleSIMessage(char* pPushBody, int PushBodyLen, memset(&msgInfo, 0, sizeof(MSG_MESSAGE_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); createMsgInfo(&msgInfo); @@ -1727,7 +1728,7 @@ void SmsPluginWapPushHandler::handleSLMessage(char* pPushBody, int PushBodyLen, memset(&msgInfo, 0, sizeof(MSG_MESSAGE_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); createMsgInfo(&msgInfo); @@ -1853,7 +1854,7 @@ void SmsPluginWapPushHandler::handleCOMessage(char* pPushBody, int PushBodyLen, memset(&msgInfo, 0, sizeof(MSG_MESSAGE_INFO_S)); msgInfo.addressList = NULL; - AutoPtr<MSG_ADDRESS_INFO_S> addressListBuf(&msgInfo.addressList); + unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter); createMsgInfo(&msgInfo); @@ -1893,7 +1894,7 @@ void SmsPluginWapPushHandler::handleDrmVer1(char* pPushBody, int PushBodyLen) #if MSG_DRM_SUPPORT int drmRt = DRM_RETURN_SUCCESS; char* cid = NULL; - AutoPtr<char> buf(&cid); + unique_ptr<char*, void(*)(char**)> buf(&cid, unique_ptr_deleter); MSG_DEBUG("Received DRM RIGHTS OBJECT Type WAP Push Message."); drm_request_type_e request_type = DRM_REQUEST_TYPE_REGISTER_LICENSE; @@ -2215,12 +2216,12 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un unsigned long currentLength; char* encodedHeader = NULL; - AutoPtr<char> encodedHeaderbuf(&encodedHeader); + unique_ptr<char*, void(*)(char**)> encodedHeaderbuf(&encodedHeader, unique_ptr_deleter); char* outTemper = NULL; char* temper = NULL; - AutoPtr<char> temperbuf(&temper); + unique_ptr<char*, void(*)(char**)> temperbuf(&temper, unique_ptr_deleter); unsigned char track; unsigned long iEncodedHeader = 0; @@ -2246,7 +2247,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un for (loop = 0 ; loop<(int)encodedHeaderLen; loop++) { char szTempBuf[5]; szTempBuf[0] = 0x00; - sprintf( szTempBuf, "%2X ", sEncodedHeader[loop] ); + snprintf( szTempBuf, sizeof(szTempBuf), "%2X ", sEncodedHeader[loop] ); if (AcStrlen( szBuf ) + 7 < 64) { strncat( szBuf, szTempBuf, sizeof(szBuf)-AcStrlen(szBuf)-1 ); @@ -2453,7 +2454,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un /* If parameter exist */ if (iField < fieldValueLen) { char* param = NULL; - AutoPtr<char> parambuf(¶m); + unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter); wspHeaderDecodeQValue( fieldValueLen - iField, fieldValue + iField, ¶m); strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); } @@ -2560,7 +2561,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un /* If there is a parameter */ if (tempLen < fieldValueLen) { char* param = NULL; - AutoPtr<char> parambuf(¶m); + unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter); wspHeaderDecodeParameter( fieldValue + tempLen, fieldValueLen - tempLen, ¶m); if (param != NULL) { strncat( (char*)temper, "; ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1); @@ -2606,7 +2607,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un if (tempLen < fieldValueLen) { char* param = NULL; - AutoPtr<char> parambuf(¶m); + unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter); wspHeaderDecodeQValue( fieldValueLen - tempLen, fieldValue + tempLen, ¶m ); strncat( (char*)temper, (char*)param, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); } @@ -2632,7 +2633,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un AcSprintf( (char*)temp, "%u", (unsigned int)fieldValue[1]); else */ - sprintf( (char*)temp, "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue, fieldValueLen )); + snprintf( (char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue, fieldValueLen )); strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); } break; @@ -2674,7 +2675,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un AcSprintf( (char*)temp, "%u", (unsigned int)fieldValue[0]); else */ - sprintf( (char*)temp, "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue, fieldValueLen )); + snprintf( (char*)temp, sizeof(temp), "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue, fieldValueLen )); strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1); } break; @@ -2695,7 +2696,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un case 0x12 : { char* decodedString = NULL; - AutoPtr<char> decodedStringbuf(&decodedString); + unique_ptr<char*, void(*)(char**)> decodedStringbuf(&decodedString, unique_ptr_deleter); wspHeaderDecodeDateValue( fieldValueLen, fieldValue, &decodedString); strncat( (char*)temper, (char*)decodedString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen(temper)-1 ); } @@ -2729,7 +2730,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un case 0x21 : if (fieldValue[0] == 0x80) { char* addString = NULL; - AutoPtr<char> addStringbuf(&addString); + unique_ptr<char*, void(*)(char**)> addStringbuf(&addString, unique_ptr_deleter); wspHeaderDecodeAuth(fieldValueLen, fieldValue, &addString ); strncat( (char*)temper, addString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); } else { @@ -2738,7 +2739,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un strncat( (char*)temper, (char*)fieldValue, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); if (iField < fieldValueLen) { char* param = NULL; - AutoPtr<char> parambuf(¶m); + unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter); wspHeaderDecodeParameter( fieldValue + 1, fieldValueLen - 1, ¶m ); if (param != NULL) { strncat( (char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); @@ -2758,7 +2759,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un break; if (fieldValue[0] == 0x80) { char* addString = NULL; - AutoPtr<char> addStringbuf(&addString); + unique_ptr<char*, void(*)(char**)> addStringbuf(&addString, unique_ptr_deleter); wspHeaderDecodeChallenge(fieldValueLen, fieldValue, &addString ); strncat( (char*)temper, addString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); } else { @@ -2775,7 +2776,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un if (iField < fieldValueLen) { char* param = NULL; - AutoPtr<char> parambuf(¶m); + unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter); wspHeaderDecodeParameter( fieldValue + iField, fieldValueLen - iField, ¶m ); if (param != NULL) { strncat( (char*)temper, ", ", (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); @@ -2801,7 +2802,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un */ last = first + contentsLength - 1; - sprintf( (char*)temp, "%u-%u/%u", (unsigned int)first, (unsigned int)last, (unsigned int)len ); + snprintf( (char*)temp, sizeof(temp), "%u-%u/%u", (unsigned int)first, (unsigned int)last, (unsigned int)len ); strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); } break; @@ -2810,7 +2811,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un case 0x08 : { char* cacheString = NULL; - AutoPtr<char> cacheStringbuf(&cacheString); + unique_ptr<char*, void(*)(char**)> cacheStringbuf(&cacheString, unique_ptr_deleter); wspHeaderDecodeCacheControl( fieldValue, fieldValueLen, &cacheString ); strncat( (char*)temper, (char*)cacheString, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); @@ -2824,7 +2825,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un } else { if (1 < fieldValueLen) { char* param = NULL; - AutoPtr<char> parambuf(¶m); + unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter); wspHeaderDecodeParameter( fieldValue, fieldValueLen, ¶m ); if (param != NULL) { @@ -2856,7 +2857,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un first = wspRetriveUintvarDecode( fieldValue, &iField ); last = wspRetriveUintvarDecode( fieldValue, &iField ); - sprintf( (char*)temp, "%u-%u", (unsigned int)first, (unsigned int)last ); + snprintf( (char*)temp, sizeof(temp), "%u-%u", (unsigned int)first, (unsigned int)last ); strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); } if (fieldValue[0] == 0x81) { @@ -2865,7 +2866,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un suffix = wspRetriveUintvarDecode( fieldValue, &iField ); - sprintf( (char*)temp, "-%u", (unsigned int)suffix ); + snprintf( (char*)temp, sizeof(temp), "-%u", (unsigned int)suffix ); } break; @@ -2873,7 +2874,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un case 0x25 : if (fieldValue[0] == 0x80) { char* temp = NULL; - AutoPtr<char> tempbuf(&temp); + unique_ptr<char*, void(*)(char**)> tempbuf(&temp, unique_ptr_deleter); wspHeaderDecodeDateValue( fieldValueLen - 1, fieldValue + 1, &temp ); strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); @@ -2882,7 +2883,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un if (fieldValue[0] == 0x81) { unsigned char temp[16]; - sprintf( (char*)temp, "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue,fieldValueLen )); + snprintf( (char*)temp, 16, "%u", (unsigned int)wspHeaderDecodeIntegerByLength( fieldValue,fieldValueLen )); strncat( (char*)temper, (char*)temp, (WSP_STANDARD_STR_LEN_MAX * 5)-AcStrlen((char*)temper)-1 ); } break; @@ -2937,7 +2938,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un if (1 < fieldValueLen) { char* param = NULL; - AutoPtr<char> parambuf(¶m); + unique_ptr<char*, void(*)(char**)> parambuf(¶m, unique_ptr_deleter); wspHeaderDecodeParameter( fieldValue + 1, fieldValueLen - 1, ¶m ); if (param != NULL) { @@ -2966,7 +2967,7 @@ void SmsPluginWapPushHandler::wspDecodeHeader( unsigned char* sEncodedHeader, un if (fieldValueLen > ( AcStrlen( (char*)(fieldValue + 1)) + 1 )) { /* copy warn-date */ char* decodedString = NULL; - AutoPtr<char> decodedStringbuf(&decodedString); + unique_ptr<char*, void(*)(char**)> decodedStringbuf(&decodedString, unique_ptr_deleter); wspHeaderDecodeDateValue( fieldValueLen - ( AcStrlen( (char*)(fieldValue + 1)) + 2 ), fieldValue + AcStrlen( (char*)(fieldValue + 1)) + 1, &decodedString ); strncat( (char*)temp, (char*)decodedString, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)temp)-1 ); } @@ -3058,7 +3059,7 @@ void SmsPluginWapPushHandler::wspHeaderDecodeQValue( unsigned long length, unsig if (qValue > 100) { qValue = qValue - 100; qValue = qValue / 1000; - sprintf( (char*)*pDecodedString, "; q=%.3f", qValue ); + snprintf( (char*)*pDecodedString, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "; q=%.3f", qValue ); } else { /* qValue variable is divided by 100. And it's multiplied by 100. It's to resolve problem of changed 0.01 of qValue. */ @@ -3067,9 +3068,9 @@ void SmsPluginWapPushHandler::wspHeaderDecodeQValue( unsigned long length, unsig qValue = qValue / 100; qValueTemp = (unsigned long)(qValue * 100); if (0 == (qValueTemp % 10 )) - sprintf( (char*)*pDecodedString, "; q=%.1f", qValue ); + snprintf( (char*)*pDecodedString, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "; q=%.1f", qValue ); else - sprintf( (char*)*pDecodedString, "; q=%.2f", qValue ); + snprintf( (char*)*pDecodedString, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "; q=%.2f", qValue ); } return; } @@ -3138,7 +3139,7 @@ void SmsPluginWapPushHandler::wspHeaderDecodeParameter( unsigned char* data, uns } strncat( (char*)param, "=", WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1 ); - strncat( (char*)param, (char*)(data + AcStrlen( (char*)param )), WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1); + strncat( (char*)param, (char*)(data + strlen( (char*)param )), WSP_STANDARD_STR_LEN_MAX-strlen((char*)param)-1); *pParam = param; @@ -3164,7 +3165,7 @@ void SmsPluginWapPushHandler::wspHeaderDecodeParameter( unsigned char* data, uns MSG_DEBUG("WspLHeaderDecodeParameter: 0x03 MemAlloc failed\n"); return; } else { - sprintf( (char*)param, "Type=%i", (int)wspHeaderDecodeInteger( data + 1 )); + snprintf((char*)param, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "Type=%i", (int)wspHeaderDecodeInteger( data + 1 )); } break; case 0x08 : @@ -3174,7 +3175,7 @@ void SmsPluginWapPushHandler::wspHeaderDecodeParameter( unsigned char* data, uns MSG_DEBUG("WspLHeaderDecodeParameter:0x08 MemAlloc failed\n"); return; } else { - sprintf( (char*)param, "Padding=%i", (int)wspHeaderDecodeInteger( data + 1 )); + snprintf((char*)param, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "Padding=%i", (int)wspHeaderDecodeInteger( data + 1 )); } break; case 0x05 : @@ -3241,31 +3242,41 @@ void SmsPluginWapPushHandler::wspHeaderDecodeParameter( unsigned char* data, uns void SmsPluginWapPushHandler::wspHeaderDecodeCharset( unsigned long length, unsigned char* data, char**pDecodedString) { - *pDecodedString = new char[WSP_STANDARD_STR_LEN_MAX]; + char* param = NULL; - if (*pDecodedString == NULL) { + param = new char[WSP_STANDARD_STR_LEN_MAX]; + + if (param == NULL) { MSG_DEBUG("WspLHeaderDecodeCharset:MemAlloc failed\n"); + *pDecodedString = NULL; return; } - strncpy( (char*)*pDecodedString, "charset=", WSP_STANDARD_STR_LEN_MAX-1); + strncpy( (char*)param, "charset=", WSP_STANDARD_STR_LEN_MAX-1); if (data[0] > 0x80) { unsigned long code = wspHeaderDecodeInteger(data ); unsigned long i = 0; while (wspCharset[i].charsetCode != code) { if (wspCharset[i].charsetCode == 0xffff) { + *pDecodedString = param; return; } i++; } - strncat( (char*)*pDecodedString, (char*)wspCharset[i].charsetName, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)*pDecodedString)-1 ); + strncat( (char*)param, (char*)wspCharset[i].charsetName, WSP_STANDARD_STR_LEN_MAX-AcStrlen((char*)param)-1 ); } else { - unsigned long lastLen = AcStrlen((char*)*pDecodedString); - memcpy( (char*)(*pDecodedString + lastLen), data, (size_t)length ); - *pDecodedString[length + lastLen] = '\0'; + unsigned long lastLen = AcStrlen((char*)param); + if (length + lastLen < WSP_STANDARD_STR_LEN_MAX - 1) { + memcpy( (char*)(param + lastLen), data, (size_t)length ); + param[length + lastLen] = '\0'; + } else { + memcpy( (char*)(param + lastLen), data, WSP_STANDARD_STR_LEN_MAX - lastLen - 1 ); + param[WSP_STANDARD_STR_LEN_MAX-1] = '\0'; + } } + *pDecodedString = param; return; } @@ -3287,7 +3298,7 @@ void SmsPluginWapPushHandler::wspHeaderDecodeVersion( unsigned long length, unsi /* typed version */ unsigned char majorVer = ((data[0] & 0x7f ) >> 4 ); unsigned char minorVer = data[0] & 0x0f; - sprintf( (char*)*pDecodedString, "level=%u.%u", majorVer, minorVer ); + snprintf( (char*)*pDecodedString, sizeof(char)*WSP_STANDARD_STR_LEN_MAX, "level=%u.%u", majorVer, minorVer ); } return; @@ -3297,7 +3308,7 @@ void SmsPluginWapPushHandler::wspHeaderDecodeVersion( unsigned long length, unsi void SmsPluginWapPushHandler::wspHeaderDecodeDateValue( unsigned long length, unsigned char* data, char** pDecodedString ) { time_t lTime; - struct tm* pTMData; + struct tm pTMData; MSG_DEBUG("WspLHeaderDecodeDateValue: \n" ); @@ -3310,19 +3321,13 @@ void SmsPluginWapPushHandler::wspHeaderDecodeDateValue( unsigned long length, un lTime = wspHeaderDecodeIntegerByLength(data, length); - pTMData = (struct tm*)gmtime((const time_t* )&lTime); - - if (pTMData == NULL) { - MSG_DEBUG( "WspLHeaderDecodeDateValue: Date decode fail \n" ); - strncpy( (char*)*pDecodedString, "Decoding Failed", WSP_STANDARD_STR_LEN_MAX-1); - return; - } + (struct tm*)gmtime_r((const time_t* )&lTime, &pTMData); /* check date value validity */ { - if (( pTMData->tm_wday > 6 ) || (pTMData->tm_mon > 11 ) || (pTMData->tm_mday > 31 )) + if (( pTMData.tm_wday > 6 ) || (pTMData.tm_mon > 11 ) || (pTMData.tm_mday > 31 )) { - MSG_DEBUG( "WspLHeaderDecodeDateValue: Date decode fail %d, %d, %d \n", pTMData->tm_wday, pTMData->tm_mon, pTMData->tm_mday ); + MSG_DEBUG( "WspLHeaderDecodeDateValue: Date decode fail %d, %d, %d \n", pTMData.tm_wday, pTMData.tm_mon, pTMData.tm_mday ); strncpy( (char*)*pDecodedString, "Decoding Failed", WSP_STANDARD_STR_LEN_MAX-1); return; } @@ -3334,25 +3339,25 @@ void SmsPluginWapPushHandler::wspHeaderDecodeDateValue( unsigned long length, un { /* UNIX asciitime function */ case UNIX_DATE_TYPE : - snprintf( (char*)decodedString, sizeof(decodedString), "%s %s %-2u %u:%u:%u %u GMT", wspWeek[pTMData->tm_wday], wspMonth[pTMData->tm_mon], - pTMData->tm_mday, pTMData->tm_hour, pTMData->tm_min, pTMData->tm_sec, pTMData->tm_year + 1900 ); + snprintf( (char*)decodedString, sizeof(decodedString), "%s %s %-2u %u:%u:%u %u GMT", wspWeek[pTMData.tm_wday], wspMonth[pTMData.tm_mon], + pTMData.tm_mday, pTMData.tm_hour, pTMData.tm_min, pTMData.tm_sec, pTMData.tm_year + 1900 ); break; case RFC1123_DATE_TYPE : - snprintf( (char*)decodedString, sizeof(decodedString), "%s, %u %s %u %u:%u:%u GMT", wspWeek[pTMData->tm_wday], pTMData->tm_mday, - wspMonth[pTMData->tm_mon], pTMData->tm_year + 1900, pTMData->tm_hour, pTMData->tm_min, pTMData->tm_sec ); + snprintf( (char*)decodedString, sizeof(decodedString), "%s, %u %s %u %u:%u:%u GMT", wspWeek[pTMData.tm_wday], pTMData.tm_mday, + wspMonth[pTMData.tm_mon], pTMData.tm_year + 1900, pTMData.tm_hour, pTMData.tm_min, pTMData.tm_sec ); break; case RFC850_DATE_TYPE : /* Have some Y2K Problems */ /* In RFC 850, date is represented like 11-May-99. So Y2K problem always can be occured. So remainer (year divided by 100) is used. */ - snprintf( (char*)decodedString, sizeof(decodedString), "%s, %2u-%s-%2u %u:%u:%u GMT", wspWeekDay[pTMData->tm_wday], pTMData->tm_mday, - wspMonth[pTMData->tm_mon], pTMData->tm_year % CENTURY, pTMData->tm_hour, pTMData->tm_min, pTMData->tm_sec ); + snprintf( (char*)decodedString, sizeof(decodedString), "%s, %2u-%s-%2u %u:%u:%u GMT", wspWeekDay[pTMData.tm_wday], pTMData.tm_mday, + wspMonth[pTMData.tm_mon], pTMData.tm_year % CENTURY, pTMData.tm_hour, pTMData.tm_min, pTMData.tm_sec ); break; } #endif /**UNIX_DATE_TYPE : */ - snprintf( (char*)*pDecodedString, (sizeof(char)*WSP_STANDARD_STR_LEN_MAX), "%s %s %-2u %u:%u:%u %u GMT", wspWeek[pTMData->tm_wday], wspMonth[pTMData->tm_mon], - pTMData->tm_mday, pTMData->tm_hour, pTMData->tm_min, pTMData->tm_sec, pTMData->tm_year + 1900 ); + snprintf( (char*)*pDecodedString, (sizeof(char)*WSP_STANDARD_STR_LEN_MAX), "%s %s %-2u %u:%u:%u %u GMT", wspWeek[pTMData.tm_wday], wspMonth[pTMData.tm_mon], + pTMData.tm_mday, pTMData.tm_hour, pTMData.tm_min, pTMData.tm_sec, pTMData.tm_year + 1900 ); return; @@ -3401,11 +3406,11 @@ void SmsPluginWapPushHandler::wspHeaderDecodeAuth(unsigned long fieldValueLen, u /* skip 'basic' code */ iField++; memset(authStr, 0x00, sizeof(authStr)); - snprintf(authStr, sizeof(authStr), "%%%us", sizeof(userId)); + snprintf(authStr, sizeof(authStr), "%%%ds", sizeof(userId)); sscanf((char*)(fieldValue + iField), authStr, userId ); iField = iField + AcStrlen( (char*)userId ) + 1; memset(authStr, 0x00, sizeof(authStr)); - snprintf(authStr, sizeof(authStr), "%%%us", sizeof(passWd)); + snprintf(authStr, sizeof(authStr), "%%%ds", sizeof(passWd)); sscanf( (char*)(fieldValue + iField), authStr, passWd ); iField = iField + AcStrlen( (char*)userId ) + 1; snprintf( (char*)*pDecodedString, (sizeof(char)*WSP_STANDARD_STR_LEN_MAX*2), "basic %s/%s", userId, passWd ); @@ -3430,7 +3435,7 @@ void SmsPluginWapPushHandler::wspHeaderDecodeChallenge(unsigned long fieldValueL /* skip 'basic' code */ iField++; memset(authStr, 0x00, sizeof(authStr)); - snprintf(authStr, sizeof(authStr), "%%%us", sizeof(userId)); + snprintf(authStr, sizeof(authStr), "%%%ds", sizeof(userId)); sscanf( (char*)(fieldValue + iField), authStr, userId ); iField = iField + AcStrlen( (char*)userId ) + 1; diff --git a/plugin/sms_plugin/include/SmsPluginCbMsgHandler.h b/plugin/sms_plugin/include/SmsPluginCbMsgHandler.h index ae04ee5..c351889 100755 --- a/plugin/sms_plugin/include/SmsPluginCbMsgHandler.h +++ b/plugin/sms_plugin/include/SmsPluginCbMsgHandler.h @@ -80,14 +80,14 @@ private: unsigned short encodeCbSerialNum ( SMS_CBMSG_SERIAL_NUM_S snFields ); int CMAS_class(unsigned short message_id); - bool checkCbOpt(SMS_CBMSG_PAGE_S CbPage, bool *pJavaMsg, msg_sim_slot_id_t simIndex); - unsigned char checkCbPage(SMS_CBMSG_PAGE_S CbPage); - void MakeCbMsg(SMS_CBMSG_PAGE_S CbPage, SMS_CBMSG_S *pCbMsg); + bool checkCbOpt(SMS_CBMSG_PAGE_S *CbPage, bool *pJavaMsg, msg_sim_slot_id_t simIndex); + unsigned char checkCbPage(SMS_CBMSG_PAGE_S *CbPage); + void MakeCbMsg(SMS_CBMSG_PAGE_S *CbPage, SMS_CBMSG_S *pCbMsg); void convertCbMsgToMsginfo(SMS_CBMSG_S *pCbMsg, MSG_MESSAGE_INFO_S *pMsgInfo, msg_sim_slot_id_t simIndex); - void convertEtwsMsgToMsginfo(SMS_CBMSG_PAGE_S EtwsMsg, MSG_MESSAGE_INFO_S *pMsgInfo, msg_sim_slot_id_t simIndex); + void convertEtwsMsgToMsginfo(SMS_CBMSG_PAGE_S *EtwsMsg, MSG_MESSAGE_INFO_S *pMsgInfo, msg_sim_slot_id_t simIndex); int convertTextToUtf8 (unsigned char* outBuf, int outBufSize, SMS_CBMSG_S* pCbMsg); - void addToPageList(SMS_CBMSG_PAGE_S CbPage); - void removeFromPageList(SMS_CBMSG_PAGE_S CbPage); + void addToPageList(SMS_CBMSG_PAGE_S *CbPage); + void removeFromPageList(SMS_CBMSG_PAGE_S *CbPage); void decodeCbMsgDCS(unsigned char dcsData, const unsigned char *pMsgData, SMS_CBMSG_DCS_S* pDcs); void convertLangType(SMS_CBMSG_LANG_TYPE_T InType , MSG_CB_LANGUAGE_TYPE_T *pOutType); diff --git a/plugin/sms_plugin/include/SmsPluginSimMsg.h b/plugin/sms_plugin/include/SmsPluginSimMsg.h index fed6a1a..900ddcf 100755 --- a/plugin/sms_plugin/include/SmsPluginSimMsg.h +++ b/plugin/sms_plugin/include/SmsPluginSimMsg.h @@ -47,7 +47,6 @@ public: msg_error_t saveSimMessage(const MSG_MESSAGE_INFO_S *pMsgInfo, SMS_SIM_ID_LIST_S *pSimIdList); msg_error_t saveClass2Message(const MSG_MESSAGE_INFO_S *pMsgInfo); void deleteSimMessage(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMsgId); - void getSimMessageList(MSG_SIM_MSG_INFO_LIST_S **ppSimMsgList); void setReadStatus(msg_sim_slot_id_t sim_idx, msg_sim_id_t SimMsgId); bool checkSimMsgFull(msg_sim_slot_id_t sim_idx, unsigned int SegCnt); diff --git a/plugin/sms_plugin/include/SmsPluginUAManager.h b/plugin/sms_plugin/include/SmsPluginUAManager.h index a23e2d2..8a50cab 100755 --- a/plugin/sms_plugin/include/SmsPluginUAManager.h +++ b/plugin/sms_plugin/include/SmsPluginUAManager.h @@ -51,8 +51,6 @@ private: static SmsPluginUAManager* pInstance; - bool bRunning; - MsgSimpleQ <SMS_REQUEST_INFO_S> smsTranQ; Mutex mx; |