modify ipcbuffer to remove memory leak
[platform/framework/native/appfw.git] / src / security / cert / FSecCert_CertServiceProxy.cpp
index b51a001..56f5ca1 100755 (executable)
@@ -1,5 +1,4 @@
 //
-// Open Service Platform
 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
 //
 // Licensed under the Apache License, Version 2.0 (the License);
@@ -175,7 +174,7 @@ _CertServiceProxy::GetNextCertificate(int certType, int& curPos, byte* pBuffer,
        result r = E_SUCCESS;
        result ret = E_SUCCESS;
 
-       Tizen::Io::_IpcBuffer certBufferIpc;
+       Tizen::Base::ByteBuffer certBufferIpc;
 
        ClearLastResult();
 
@@ -184,9 +183,6 @@ _CertServiceProxy::GetNextCertificate(int certType, int& curPos, byte* pBuffer,
        SysTryReturnResult(NID_SEC_CERT, certType > _CERT_TYPE_NOT_BOUNDED, E_INVALID_ARG, "Invalid certificate type.");
        SysTryReturnResult(NID_SEC_CERT, certType < _CERT_TYPE_MAX, E_INVALID_ARG, "Invalid certificate type.");
 
-       certBufferIpc.pBuffer = null;
-       certBufferIpc.size = 0;
-
        std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_GetNextCertificate(certType, curPos, bufferLen, &certBufferIpc, &curPos, &ret));
        SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
 
@@ -194,8 +190,8 @@ _CertServiceProxy::GetNextCertificate(int certType, int& curPos, byte* pBuffer,
        SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
        SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
 
-       memcpy(pBuffer, certBufferIpc.pBuffer, certBufferIpc.size);
-       bufferLen = certBufferIpc.size;
+       memcpy(pBuffer, certBufferIpc.GetPointer(), certBufferIpc.GetRemaining());
+       bufferLen = certBufferIpc.GetRemaining();
 
        return r;
 }
@@ -549,4 +545,21 @@ _CertServiceProxy::GetUserCertFieldInfoByCertId(int certId, _CertFieldInfos* pCe
 
        return r;
 }
+
+void
+_CertServiceProxy::RestoreRootCaIntegrity(void)
+{
+       result r = E_SUCCESS;
+
+       ClearLastResult();
+
+       SysTryReturnVoidResult(NID_SEC_CERT, __pIpcClient != null, E_SYSTEM, "[%s] IPC instance is not constructed.", GetErrorMessage(E_SYSTEM));
+
+       std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_RestoreRootCaIntegrity());
+       SysTryReturnVoidResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "[%s] Failed to allocate memory.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+       r = __pIpcClient->SendRequest(pMessage.get());
+       SysTryReturnVoidResult(NID_SEC_CERT, !IsFailed(r), r, "[%s] Failed to send message.", GetErrorMessage(r));
+}
+
 } } }