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: js126.lee <js126.lee@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/14327
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Chul Lee <chuls.lee@samsung.com>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
Reviewed-by: Randeep Singh <randeep.s@samsung.com>
(cherry picked from commit
39f4a884082aa687f86fc24296b37401780dc9cb)
Reviewed-on: https://gerrit.iotivity.org/gerrit/14441
//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;
}
{
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;
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;
}
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;
}