Fix for Klockwork issues
authorkoushik.girijala <g.koushik@samsung.com>
Tue, 8 Mar 2016 06:03:29 +0000 (11:33 +0530)
committerJon A. Cruz <jon@joncruz.org>
Fri, 11 Mar 2016 09:23:00 +0000 (09:23 +0000)
Fixed issues reported in Klockwork run

Change-Id: Icc1fb0d2d0e3aa9662fa50e17d2d821e8407c4a4
Signed-off-by: koushik.girijala <g.koushik@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/5663
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: jihwan seo <jihwan.seo@samsung.com>
Reviewed-by: Jon A. Cruz <jon@joncruz.org>
resource/csdk/connectivity/src/bt_edr_adapter/caedradapter.c
resource/csdk/connectivity/src/cablockwisetransfer.c
resource/csdk/connectivity/src/cainterfacecontroller.c
resource/csdk/connectivity/src/ip_adapter/caipserver.c

index ed5c47a..9a1c018 100644 (file)
@@ -590,6 +590,12 @@ void CAAdapterDataReceiverHandler(void *context)
                                                           message->remoteEndpoint->addr,
                                                           0);
 
+    if (!remoteEndpoint)
+    {
+        OIC_LOG(ERROR, EDR_ADAPTER_TAG, "remoteEndpoint is NULL");
+        return;
+    }
+
     OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "Sending data up !");
 
     const CASecureEndpoint_t sep = { .endpoint = *remoteEndpoint };
index 140456a..1f02016 100644 (file)
@@ -421,6 +421,11 @@ CAResult_t CAReceiveBlockWiseData(coap_pdu_t *pdu, const CAEndpoint_t *endpoint,
                     return res;
                 }
             }
+            else
+            {
+                CADestroyBlockID(blockDataID);
+                return CA_STATUS_FAILED;
+            }
         }
         else
         {
@@ -2582,6 +2587,14 @@ CABlockData_t *CACreateNewBlockData(const CAData_t *sendData)
         token = data->sentData->responseInfo->info.token;
     }
 
+    if (!data->sentData->remoteEndpoint)
+    {
+        OIC_LOG(ERROR, TAG, "remoteEndpoint is null");
+        CADestroyDataSet(data->sentData);
+        OICFree(data);
+        return NULL;
+    }
+
     CABlockDataID_t* blockDataID = CACreateBlockDatablockId(
             token, tokenLength,
             data->sentData->remoteEndpoint->port);
index 7ef5926..a21f5b5 100644 (file)
@@ -289,13 +289,16 @@ CAResult_t CAGetNetworkInfo(CAEndpoint_t **info, uint32_t *size)
 
     if (resSize == 0)
     {
+        OICFree(tempInfo);
+        OICFree(tempSize);
         if (res == CA_ADAPTER_NOT_ENABLED || res == CA_NOT_SUPPORTED)
         {
-            OICFree(tempInfo);
-            OICFree(tempSize);
             return res;
         }
-        return CA_STATUS_FAILED;
+        else
+        {
+            return CA_STATUS_FAILED;
+        }
     }
 
     // #3. add data into result
index f1b133c..1f53541 100644 (file)
@@ -793,7 +793,7 @@ static void CAHandleNetlink()
 
     for (nh = (struct nlmsghdr *)buf; NLMSG_OK(nh, len); nh = NLMSG_NEXT(nh, len))
     {
-        if (nh->nlmsg_type != RTM_NEWLINK)
+        if (nh != NULL && nh->nlmsg_type != RTM_NEWLINK)
         {
             continue;
         }