Commit 39f4a884 authored by js126.lee's avatar js126.lee Committed by Randeep

[IOT-1550] Resolved reset issue on rowner of cred

https://jira.iotivity.org/browse/IOT-1550

issue : Rowner of cred is reset, when saving Cert. chain
        using SRPSaveTrustCertChain and SRPSaveOwnCertChain.

Patch 1: upload patch
Patch 2: rebase
Patch 3: Apply review comment

Change-Id: I59cdbfb30253c61e1c27dcf640958899af976a96
Signed-off-by: default avatarjs126.lee <js126.lee@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/14327Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: default avatarChul Lee <chuls.lee@samsung.com>
Reviewed-by: default avatarUze Choi <uzchoi@samsung.com>
Reviewed-by: Randeep's avatarRandeep Singh <randeep.s@samsung.com>
parent b92495d1
......@@ -1519,7 +1519,7 @@ OCStackResult AddCredential(OicSecCred_t * newCred)
//the newCred is not valid if it is empty
if (memcmp(&(newCred->subject.id), &emptyOwner, UUID_IDENTITY_SIZE) == 0)
if (memcmp(&(newCred->subject), &emptyOwner, sizeof(OicUuid_t)) == 0)
{
validFlag = false;
}
......@@ -1553,8 +1553,10 @@ OCStackResult AddCredential(OicSecCred_t * newCred)
{
LL_APPEND(gCred, newCred);
}
memcpy(&(gCred->rownerID), &(newCred->rownerID), sizeof(OicUuid_t));
if (memcmp(&(newCred->rownerID), &emptyOwner, sizeof(OicUuid_t)) != 0)
{
memcpy(&(gCred->rownerID), &(newCred->rownerID), sizeof(OicUuid_t));
}
if (UpdatePersistentStorage(gCred))
{
ret = OC_STACK_OK;
......
......@@ -229,11 +229,11 @@ static int saveTrustCert(void)
size_t fsize;
if (fseeko(fp, 0, SEEK_END) == 0 && (fsize = ftello(fp)) > 0)
{
trustCertChainArray.data = (uint8_t*)OICCalloc(1, fsize+1);
trustCertChainArray.len = fsize+1;
trustCertChainArray.data = (uint8_t*)OICCalloc(1, fsize);
trustCertChainArray.len = fsize;
if (NULL == trustCertChainArray.data)
{
OIC_LOG(ERROR,TAG,"OICCalloc");
OIC_LOG(ERROR,TAG,"Failed to allocate memory");
fclose(fp);
return res;
}
......
......@@ -817,11 +817,11 @@ static int saveTrustCert(void)
size_t fsize;
if (fseeko(fp, 0, SEEK_END) == 0 && (fsize = ftello(fp)) >= 0)
{
trustCertChainArray.data = (uint8_t*)OICMalloc(fsize);
trustCertChainArray.data = (uint8_t*)OICCalloc(1, fsize);
trustCertChainArray.len = fsize;
if (NULL == trustCertChainArray.data)
{
OIC_LOG(ERROR,TAG,"malloc");
OIC_LOG(ERROR,TAG,"Failed to allocate memory");
fclose(fp);
return -1;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment