Fixed prevent issues.
authorBhanu Singh Rao <bhanu.singh@samsung.com>
Mon, 12 Aug 2013 12:55:44 +0000 (18:25 +0530)
committerBhanu Singh Rao <bhanu.singh@samsung.com>
Mon, 12 Aug 2013 12:55:44 +0000 (18:25 +0530)
Change-Id: I3a85f1ccb9a57f9bf96922459697b1739837a55c
Signed-off-by: Bhanu Singh Rao <bhanu.singh@samsung.com>
src/security/cert/FSecCert_CertDbManager.cpp
src/security/cert/FSecCert_CertServer.cpp

index 99d384d..5428061 100755 (executable)
@@ -1556,8 +1556,6 @@ _CertDbManager::InsertUserCertificateFromBuffer(_CertFormat certFormat, byte* pC
        int lenSerialNo = 0;
        int certId = 0;
        int keyIdB64Length = 0;
-       char* pFileName = null;
-       char* pPriKeyFileName = null;
        char subjectNameBuffer[_MAX_ISSUER_SUBJECT_NAME_SIZE] = {0, };
        char szIssuerName[_MAX_ISSUER_SUBJECT_NAME_SIZE] = {0, };
        char serialName[_MAX_SERIAL_NUMBER_SIZE] = {0, };
@@ -1638,7 +1636,6 @@ _CertDbManager::InsertUserCertificateFromBuffer(_CertFormat certFormat, byte* pC
        }
        else
        {
-               pPriKeyFileName = null;
                privateKeyLen = 0;
        }
 
@@ -1652,20 +1649,20 @@ _CertDbManager::InsertUserCertificateFromBuffer(_CertFormat certFormat, byte* pC
        memcpy(certRecord.certPubKeyHash, pId64.get(), keyIdB64Length); //Base64 encoded device id
        certRecord.certFormat = static_cast< int >(certFormat);
 
-       pFileName = Tizen::Base::_StringConverter::CopyToCharArrayN(tempFileName);
+       std::unique_ptr< char > pFileName(Tizen::Base::_StringConverter::CopyToCharArrayN(tempFileName));
        SysTryReturnResult(NID_SEC_CERT, pFileName != null, E_SYSTEM, "Failed to get attributes.");
 
-       strcpy(certRecord.fileName, pFileName);
+       strcpy(certRecord.fileName, pFileName.get());
        certRecord.subjectNameLen = lenSubjectName;
 
        memcpy(certRecord.subjectName, subjectNameBuffer, lenSubjectName);
        certRecord.issuerNameLen = lenIssuerName;
        memcpy(certRecord.issuerName, szIssuerName, lenIssuerName);
 
-       pPriKeyFileName = Tizen::Base::_StringConverter::CopyToCharArrayN(privateKeyFile);
+       std::unique_ptr< char > pPriKeyFileName(Tizen::Base::_StringConverter::CopyToCharArrayN(privateKeyFile));
        SysTryReturnResult(NID_SEC_CERT, pPriKeyFileName != null, E_SYSTEM, "Failed to get attributes.");
 
-       strcpy(certRecord.prvKeyPath, pPriKeyFileName);
+       strcpy(certRecord.prvKeyPath, pPriKeyFileName.get());
        certRecord.prvKeyLen = privateKeyLen;
        certRecord.parentCa = certId;
        strcpy(certRecord.installed, installedRecord);
index 0136d70..cd7a2a7 100644 (file)
@@ -937,7 +937,7 @@ _CertServer::UpdateCaCertificate(_CaCertType type, char* pOldCert, int oldCertLe
        r = pCertDb->UpdateCaCertificateFromBuffer(type, certFormat, reinterpret_cast< byte* >(pDerCertBufferOld.get()), derCertBufferLengthOld, reinterpret_cast< byte* >(pDerCertBufferNew.get()), derCertBufferLengthNew);
        if (r == E_DATA_NOT_FOUND)
        {
-               SysTryReturnResult(NID_SEC_CERT, !IsFailed(r), E_OBJ_NOT_FOUND, "Certificate not found in db.");
+               SysTryReturnResult(NID_SEC_CERT, false, E_OBJ_NOT_FOUND, "Certificate not found in db.");
        }
 
        SysTryReturnResult(NID_SEC_CERT, !IsFailed(r), E_SYSTEM, "An unexpected system error occurred.");