Fix the incorrect credential access in SRPProvisionTrustCertChain.
authorChul Lee <chuls.lee@samsung.com>
Wed, 28 Sep 2016 02:32:00 +0000 (11:32 +0900)
committerRandeep Singh <randeep.s@samsung.com>
Wed, 5 Oct 2016 11:34:14 +0000 (11:34 +0000)
SRPProvisionTrustCertChain deletes credential list.
But this credential list is read from global credential list through GetCredResourceDataByCredId API.
So credential list should not be deleted in SRPProvisionTrustCertChain.

Change-Id: I8c143d320ead4aea99daaa7d6882c11cfddf26e2
Signed-off-by: Chul Lee <chuls.lee@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/12377
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Greg Zaverucha <gregz@microsoft.com>
Reviewed-by: Randeep Singh <randeep.s@samsung.com>
(cherry picked from commit d1e4e09eafc15211e0b0a83d6aa8fb1dad8f979f)
Reviewed-on: https://gerrit.iotivity.org/gerrit/12793

resource/csdk/security/provisioning/src/secureresourceprovider.c

index 6681828..33df082 100644 (file)
@@ -697,13 +697,12 @@ OCStackResult SRPProvisionTrustCertChain(void *ctx, OicSecCredType_t type, uint1
     CertData_t *certData = (CertData_t *) OICCalloc(1, sizeof(CertData_t));
     if (NULL == certData)
     {
-        OICFree(trustCertChainCred);
         OIC_LOG(ERROR, TAG, "Memory allocation problem");
         return OC_STACK_NO_MEMORY;
     }
     certData->deviceInfo = selectedDeviceInfo;
     certData->resultCallback = resultCallback;
-    certData->credInfo = trustCertChainCred;
+    certData->credInfo = NULL; //credInfo not used in the response handler
     certData->numOfResults=0;
     certData->ctx = ctx;
 
@@ -711,7 +710,6 @@ OCStackResult SRPProvisionTrustCertChain(void *ctx, OicSecCredType_t type, uint1
     certData->resArr = (OCProvisionResult_t*)OICCalloc(noOfRiCalls, sizeof(OCProvisionResult_t));
     if (certData->resArr == NULL)
     {
-        DeleteCredList(trustCertChainCred);
         OICFree(certData);
         OCPayloadDestroy((OCPayload *)secPayload);
         OIC_LOG(ERROR, TAG, "Unable to allocate memory");
@@ -730,7 +728,6 @@ OCStackResult SRPProvisionTrustCertChain(void *ctx, OicSecCredType_t type, uint1
         OICFree(certData->resArr);
         OICFree(certData);
     }
-    DeleteCredList(trustCertChainCred);
 
     VERIFY_SUCCESS(TAG, (OC_STACK_OK == ret), ERROR, OC_STACK_ERROR);
     return OC_STACK_OK;