Removed svace defects
authorRandeep Singh <randeep.s@samsung.com>
Mon, 26 Sep 2016 06:57:01 +0000 (12:27 +0530)
committerRandeep Singh <randeep.s@samsung.com>
Thu, 29 Sep 2016 04:00:46 +0000 (04:00 +0000)
Change-Id: I63cfad7d1b507c4bcb3d6714880e14971bd231cc
Signed-off-by: Randeep Singh <randeep.s@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/12199
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Greg Zaverucha <gregz@microsoft.com>
resource/csdk/security/provisioning/sample/provisioningclient.c
resource/csdk/security/provisioning/src/ocprovisioningmanager.c
resource/csdk/security/provisioning/src/secureresourceprovider.c
resource/csdk/security/provisioning/unittest/otmunittest.cpp
resource/csdk/security/src/credresource.c
resource/csdk/security/tool/json2cbor.c
resource/provisioning/examples/provisioningclient.cpp

index ec6a5d0..402e823 100644 (file)
@@ -1242,14 +1242,14 @@ static OicSecAcl_t* createAcl(const int dev_num)
         }
         size_t len = strlen(rsrc_in)+1;  // '1' for null termination
         rsrc->href = (char*) OICCalloc(len, sizeof(char));
-        if(!rsrc)
+        if(!rsrc->href)
         {
             OIC_LOG(ERROR, TAG, "createAcl: OICCalloc error return");
             goto CRACL_ERROR;
         }
         OICStrcpy(rsrc->href, len, rsrc_in);
 
-        int arrLen = 0;
+        size_t arrLen = 0;
         while(1)
         {
             printf("         Enter Number of resource type for [%s] : ", rsrc->href);
@@ -1259,7 +1259,7 @@ static OicSecAcl_t* createAcl(const int dev_num)
                 for( ; 0x20<=getchar(); );  // for removing overflow garbages
                                             // '0x20<=code' is character region
             }
-            if(0 < arrLen && ACL_RESRC_ARRAY_SIZE >= arrLen)
+            if(ACL_RESRC_ARRAY_SIZE >= arrLen)
             {
                 break;
             }
@@ -1300,7 +1300,7 @@ static OicSecAcl_t* createAcl(const int dev_num)
                 for( ; 0x20<=getchar(); );  // for removing overflow garbages
                                             // '0x20<=code' is character region
             }
-            if(0 < arrLen && ACL_RESRC_ARRAY_SIZE >= arrLen)
+            if(ACL_RESRC_ARRAY_SIZE >= arrLen)
             {
                 break;
             }
index 0d488f4..54b9fc8 100644 (file)
@@ -460,6 +460,7 @@ OCStackResult OCRemoveDeviceWithUuid(void* ctx, unsigned short waitTimeForOwnedD
     OCStackResult res = OC_STACK_ERROR;
     OCProvisionDev_t* pTargetDev = NULL;
     bool discoverdFlag = false;
+    OCProvisionDev_t* pOwnedDevList = NULL;
 
     if (!pTargetUuid || 0 == waitTimeForOwnedDeviceDiscovery)
     {
@@ -479,7 +480,6 @@ OCStackResult OCRemoveDeviceWithUuid(void* ctx, unsigned short waitTimeForOwnedD
         goto error;
     }
 
-    OCProvisionDev_t* pOwnedDevList = NULL;
     //2. Find owned device from the network
     res = PMDeviceDiscovery(waitTimeForOwnedDeviceDiscovery, true, &pOwnedDevList);
     if (OC_STACK_OK != res)
index c030075..6681828 100644 (file)
@@ -2563,14 +2563,20 @@ OCStackResult SRPResetDevice(const OCProvisionDev_t* pTargetDev,
         goto error;
     }
     OIC_LOG_V(DEBUG, TAG, "Query=%s", query);
-
-    OCProvisionDev_t * targetDev = PMCloneOCProvisionDev(pTargetDev);
+    
     OCCallbackData cbData = { .context = NULL, .cb = NULL, .cd = NULL };
+    OCMethod method = OC_REST_POST;
+    OCDoHandle handle = NULL;
+    OCProvisionDev_t * targetDev = PMCloneOCProvisionDev(pTargetDev);
+    if (NULL == targetDev)
+    {
+        OIC_LOG(ERROR, TAG, "target dev is null");
+        res = OC_STACK_ERROR;
+        goto error;
+    }
     cbData.cb = &SRPResetDeviceCB;
     cbData.context = (void *) targetDev;
     cbData.cd = NULL;
-    OCMethod method = OC_REST_POST;
-    OCDoHandle handle = NULL;
     OIC_LOG(DEBUG, TAG, "Sending PSTAT info to resource server");
     res = OCDoResource(&handle, method, query,
             &targetDev->endpoint, (OCPayload *)secPayload,
index 4d97057..26fff98 100755 (executable)
@@ -550,10 +550,6 @@ TEST(PerformLinkDevices, NullParam)
                 dev2 = tempDev;
                 break;
             }
-            else
-            {
-                break;
-            }
         }
         tempDev = tempDev->next;
     }
index b913628..d62a32a 100644 (file)
@@ -2145,7 +2145,12 @@ void GetDerCaCert(ByteArray * crt)
                     return;
                 }
                 uint32_t outSize;
-                b64Decode(temp->optionalData.data, temp->optionalData.len, buf, bufSize, &outSize);
+                if(B64_OK != b64Decode(temp->optionalData.data, temp->optionalData.len, buf, bufSize, &outSize))
+                {
+                    OICFree(buf);
+                    OIC_LOG(ERROR, TAG, "Failed to decode base64 data");
+                    return;
+                }
                 crt->data = OICRealloc(crt->data, crt->len + outSize);
                 memcpy(crt->data + crt->len, buf, outSize);
                 crt->len += outSize;
index 9db78c1..c73aa9d 100644 (file)
@@ -410,6 +410,7 @@ OicSecAcl_t* JSONToAclBin(const char * jsonStr)
                     for(size_t i = 0; i < rsrc->typeLen; i++)
                     {
                         cJSON *jsonRsrcType = cJSON_GetArrayItem(jsonRsrcObj, i);
+                        VERIFY_NON_NULL(TAG, jsonRsrcType, ERROR);
                         rsrc->types[i] = OICStrdup(jsonRsrcType->valuestring);
                         VERIFY_NON_NULL(TAG, (rsrc->types[i]), ERROR);
                     }
@@ -426,6 +427,7 @@ OicSecAcl_t* JSONToAclBin(const char * jsonStr)
                     for(size_t i = 0; i < rsrc->interfaceLen; i++)
                     {
                         cJSON *jsonInterface = cJSON_GetArrayItem(jsonRsrcObj, i);
+                        VERIFY_NON_NULL(TAG, jsonInterface, ERROR);
                         rsrc->interfaces[i] = OICStrdup(jsonInterface->valuestring);
                         VERIFY_NON_NULL(TAG, (rsrc->interfaces[i]), ERROR);
                     }
@@ -445,7 +447,7 @@ OicSecAcl_t* JSONToAclBin(const char * jsonStr)
             if(jsonValidityObj)
             {
                 VERIFY_SUCCESS(TAG, cJSON_Array == jsonValidityObj->type, ERROR);
-                size_t validityLen = cJSON_GetArraySize(jsonValidityObj);
+                size_t validityLen = (size_t) cJSON_GetArraySize(jsonValidityObj);
                 VERIFY_SUCCESS(TAG, (0 < validityLen), ERROR);
 
                 cJSON *jsonValidity = NULL;
@@ -476,7 +478,7 @@ OicSecAcl_t* JSONToAclBin(const char * jsonStr)
                     if(jsonRecurObj)
                     {
                         VERIFY_SUCCESS(TAG, (cJSON_Array == jsonRecurObj->type), ERROR);
-                        validity->recurrenceLen = cJSON_GetArraySize(jsonRecurObj);
+                        validity->recurrenceLen = (size_t) cJSON_GetArraySize(jsonRecurObj);
                         VERIFY_SUCCESS(TAG, (0 < validity->recurrenceLen), ERROR);
 
                         validity->recurrences = (char**)OICCalloc(validity->recurrenceLen, sizeof(char*));
index 82a27be..115b52b 100644 (file)
@@ -427,7 +427,7 @@ static int InputACL(OicSecAcl_t *acl)
         OICFree(temp_rsc);
 
         char* rsrc_in = NULL;
-        int arrLen = 0;
+        size_t arrLen = 0;
         while(1)
         {
             printf("         Enter Number of resource type for [%s]: ", rsrc->href);
@@ -437,7 +437,7 @@ static int InputACL(OicSecAcl_t *acl)
                 for( ; 0x20<=getchar(); );  // for removing overflow garbages
                                             // '0x20<=code' is character region
             }
-            if(0 < arrLen && ACL_RESRC_ARRAY_SIZE >= arrLen)
+            if(ACL_RESRC_ARRAY_SIZE >= arrLen)
             {
                 break;
             }
@@ -479,7 +479,7 @@ static int InputACL(OicSecAcl_t *acl)
                 for( ; 0x20<=getchar(); );  // for removing overflow garbages
                                             // '0x20<=code' is character region
             }
-            if(0 < arrLen && ACL_RESRC_ARRAY_SIZE >= arrLen)
+            if(ACL_RESRC_ARRAY_SIZE >= arrLen)
             {
                 break;
             }
@@ -827,6 +827,10 @@ static int saveTrustCert(void)
             }
             rewind(fp);
             fsize = fread(trustCertChainArray.data, 1, fsize, fp);
+            if(0 == fsize)
+            {
+                OIC_LOG(ERROR,TAG,"Read error");
+            }
             fclose(fp);
         }
     }