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

Change-Id: I00e6a874ce53a0614ed20230d18f1470a2ec4904
Signed-off-by: koushik.girijala <g.koushik@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/5909
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
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 2e29be5..27b03d2 100644 (file)
@@ -422,6 +422,12 @@ CAResult_t CAReceiveBlockWiseData(coap_pdu_t *pdu, const CAEndpoint_t *endpoint,
                     return res;
                 }
             }
+            else
+            {
+                OIC_LOG(ERROR, TAG, "Invalid Block Option");
+                CADestroyBlockID(blockDataID);
+                return CA_STATUS_FAILED;
+            }
         }
         else
         {
@@ -2568,6 +2574,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..562a7b5 100644 (file)
@@ -289,10 +289,10 @@ 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;
index c4af3e9..c0a571e 100644 (file)
@@ -797,7 +797,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;
         }