From: Oleksii Beketov
Date: Mon, 16 Jan 2017 16:14:08 +0000 (+0200)
Subject: GetDerCrl() fix
X-Git-Tag: 1.3.0~701
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=898eb68d42d271595a51fec096e4f6a00e4c5328;p=platform%2Fupstream%2Fiotivity.git
GetDerCrl() fix
Memory leak in GetDerCrl() fixed
Change-Id: Iddf0628c73d69ce8beafa66b09b4b2f2e61e8006
Signed-off-by: Oleksii Beketov
Reviewed-on: https://gerrit.iotivity.org/gerrit/16439
Tested-by: jenkins-iotivity
Reviewed-by: Dmitriy Zhuravlev
Reviewed-by: Chul Lee
Reviewed-by: Randeep Singh
(cherry picked from commit e43d061497721cfe8fbfef623c3c4d5ae2556ce7)
Reviewed-on: https://gerrit.iotivity.org/gerrit/17059
---
diff --git a/resource/csdk/security/src/crlresource.c b/resource/csdk/security/src/crlresource.c
index f541b93..dd67cb6 100644
--- a/resource/csdk/security/src/crlresource.c
+++ b/resource/csdk/security/src/crlresource.c
@@ -807,11 +807,12 @@ void GetDerCrl(ByteArray_t* out)
{
OIC_LOG (ERROR, TAG, "Base64 decoding failed.");
}
+ OICFree(out);
}
out->len = 0;
- out->data = OICMalloc(crl->len);
+ out->data = OICRealloc(out->data, crl->len);
if (out->data)
{
memcpy(out->data, crl->data, crl->len);
diff --git a/resource/csdk/security/unittest/crlresourcetest.cpp b/resource/csdk/security/unittest/crlresourcetest.cpp
index c617a70..1aab21f 100644
--- a/resource/csdk/security/unittest/crlresourcetest.cpp
+++ b/resource/csdk/security/unittest/crlresourcetest.cpp
@@ -87,9 +87,7 @@ TEST(CRLResourceTest, CBORPayloadToCrl)
//GetDerCrl Tests
TEST(CRLResourceTest, GetDerCrl)
{
-#define CRL_MAX_LEN 1024
- uint8_t crlData[CRL_MAX_LEN] = {0};
- ByteArray crlArray = {crlData, CRL_MAX_LEN};
+ ByteArray crlArray = {NULL, 0};
GetDerCrl(&crlArray);
EXPECT_NE(0, crlArray.len);
}