Static analyzer issues fixed 86/29486/2
authorIurii Metelytsia <i.metelytsia@samsung.com>
Wed, 8 May 2019 11:15:38 +0000 (14:15 +0300)
committerAleksey Volkov <a.volkov@samsung.com>
Fri, 17 May 2019 15:55:33 +0000 (15:55 +0000)
Change-Id: I175dd965aa0c4d85dd37d5d9b4ece9b4360ff05a
Signed-off-by: Iurii Metelytsia <i.metelytsia@samsung.com>
resource/csdk/security/provisioning/sample/provisioningclient.c
resource/csdk/security/provisioning/sample/subownerclient.c
resource/csdk/security/provisioning/src/cloud/cloudresource.c
resource/csdk/security/provisioning/src/ownershiptransfermanager.c

index 7e5a5cd..540c00c 100644 (file)
@@ -1508,6 +1508,7 @@ static int provisionCloudConfig(void)
     int res = fread (cert, 1, certsize, F);
     /* Set our own trust anchor so that we trust certs we've issued. */
     res = OCSaveTrustCertChain((uint8_t*) cert, certsize, OIC_ENCODING_PEM, &g_caCredId);
+    free(cert);
     if (OC_STACK_OK != res)
     {
         printf("     Failed to setup CA\n");
index aa7a71e..04eec75 100644 (file)
@@ -400,7 +400,10 @@ static int sendGetLed(void)
             return -1;
         }
 
-        waitCallbackRet();
+        if (waitCallbackRet() != 0)
+        {
+            OIC_LOG(WARNING, TAG, "waitCallbackRet failed");
+        }
     }
     else
     {
index 7352e91..c37421e 100644 (file)
@@ -236,19 +236,22 @@ static OCEntityHandlerResult HandleCloudPostRequest(OCEntityHandlerRequest *ehRe
         {
             // find the interface name from UDP address of sender
             percentChar = strchr(ehRequest->devAddr.addr, '%');
-            size_t ifLen = strlen(percentChar);
-            size_t addrLen = strlen(newCloud->cis);
-            size_t cisLen = addrLen + ifLen + 3;
-
-            // fill the cloud uri with interface name inserted
-            cis = (char *)OICMalloc(sizeof(char) * cisLen);
-            OICStrcpy(cis, ipv6End - newCloud->cis + 1, newCloud->cis);
-            OICStrcat(cis, cisLen, "%25");
-            OICStrcat(cis, cisLen, percentChar + 1);
-            OICStrcat(cis, cisLen, ipv6End);
-
-            OICFree(newCloud->cis);
-            newCloud->cis = cis;
+            if (NULL != percentChar)
+            {
+                size_t ifLen = strlen(percentChar);
+                size_t addrLen = strlen(newCloud->cis);
+                size_t cisLen = addrLen + ifLen + 3;
+
+                // fill the cloud uri with interface name inserted
+                cis = (char *)OICMalloc(sizeof(char) * cisLen);
+                OICStrcpy(cis, ipv6End - newCloud->cis + 1, newCloud->cis);
+                OICStrcat(cis, cisLen, "%25");
+                OICStrcat(cis, cisLen, percentChar + 1);
+                OICStrcat(cis, cisLen, ipv6End);
+
+                OICFree(newCloud->cis);
+                newCloud->cis = cis;
+            }
         }
     }
 
index aa93cd8..6b739ff 100644 (file)
@@ -591,7 +591,18 @@ static void SetResult(OTMContext_t* otmCtx, const OCStackResult res)
     //If all OTM process is complete, invoke the user callback.
     if(IsComplete(otmCtx))
     {
-        SetDosState(DOS_RFNOP);
+        switch (SetDosState(DOS_RFNOP))
+        {
+        case OC_STACK_OK:
+            OIC_LOG(INFO, TAG, "DOS state SUCCESSFULLY changed to DOS_RFNOP.");
+            break;
+        case OC_STACK_FORBIDDEN_REQ:
+            OIC_LOG(WARNING, TAG, "DOS state change to DOS_RFNOP NOT ALLOWED.");
+            break;
+        default:
+            OIC_LOG(WARNING, TAG, "DOS state change to DOS_RFNOP FAILED.");
+            break;
+        }
         otmCtx->ctxResultCallback(otmCtx->userCtx, otmCtx->ctxResultArraySize,
                                    otmCtx->ctxResultArray, otmCtx->ctxHasError);
         OICFree(otmCtx->ctxResultArray);