svace fixes
[platform/upstream/iotivity.git] / resource / csdk / security / provisioning / src / secureresourceprovider.c
index 081cccd..b93fc0a 100644 (file)
@@ -586,7 +586,12 @@ OCStackResult SRPSaveTrustCertChain(uint8_t *trustCertChain, size_t chainSize,
     }
 
     cred->credUsage= (char *)OICCalloc(1, strlen(TRUST_CA)+1 );
-    VERIFY_NON_NULL_RET(TAG, cred->credUsage, ERROR, OC_STACK_NO_MEMORY);
+    if (cred->credUsage == NULL)
+    {
+        OIC_LOG_V(ERROR, TAG, "%s cant alloc credUsage", __func__);
+        OICFree(cred);
+        return OC_STACK_NO_MEMORY;
+    }
     OICStrcpy(cred->credUsage, strlen(TRUST_CA) + 1, TRUST_CA);
 
     cred->credType = SIGNED_ASYMMETRIC_KEY;
@@ -657,6 +662,12 @@ OCStackResult SRPSaveOwnCertChain(OicSecKey_t * cert, OicSecKey_t * key, uint16_
 
     cred->credUsage= (char *)OICCalloc(1, strlen(PRIMARY_CERT)+1 );
     VERIFY_NON_NULL_RET(TAG, cred->credUsage, ERROR, OC_STACK_NO_MEMORY);
+    if (cred->credUsage == NULL)
+    {
+        OIC_LOG_V(ERROR, TAG, "%s cant alloc credUsage", __func__);
+        OICFree(cred);
+        return OC_STACK_NO_MEMORY;
+    }
     OICStrcpy(cred->credUsage, strlen(PRIMARY_CERT) + 1, PRIMARY_CERT) ;
 
     cred->credType = SIGNED_ASYMMETRIC_KEY;
@@ -671,6 +682,12 @@ OCStackResult SRPSaveOwnCertChain(OicSecKey_t * cert, OicSecKey_t * key, uint16_
     OicSecKey_t *privateData = &cred->privateData;
     privateData->data = (uint8_t *)OICCalloc(1, key->len);
     VERIFY_NON_NULL_RET(TAG, privateData->data, ERROR, OC_STACK_NO_MEMORY);
+    if (privateData->data == NULL)
+    {
+        OIC_LOG_V(ERROR, TAG, "%s cant alloc publicData->data", __func__);
+        OICFree(publicData->data);
+        return OC_STACK_NO_MEMORY;
+    }
     memcpy(privateData->data, key->data, key->len);
     privateData->len = key->len;
     privateData->encoding = key->encoding;
@@ -1179,6 +1196,7 @@ static OCStackResult SendDeleteCredentialRequest(void* ctx,
     if (OC_STACK_OK != result)
     {
         OIC_LOG_V(ERROR, TAG, "SendDeleteCredentialRequest : encoding error %d\n", result);
+        OICFree(subID);
         return OC_STACK_ERROR;
     }
 
@@ -1254,6 +1272,7 @@ static OCStackResult SendDeleteACLRequest(void* ctx,
                                                      destDev->endpoint.addr);
     if (OC_STACK_OK != result)
     {
+        OICFree(subID);
         OIC_LOG_V(ERROR, TAG, "SendDeleteCredentialRequest : encoding error %d\n", result);
         return OC_STACK_ERROR;
     }