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>
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 ed5c47a49b4bd35c7086515fc07e202951384f1d..9a1c018bc3572ef08909c55bff7b3b5a568f7437 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 2e29be55d123e8296a026d35b05401c78d3d297f..27b03d284079463b3be642ec5b21a45010648a82 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 7ef59260847e658d7c175146b8717ca118d606f6..562a7b5cd442917ff20cfea8022711246ec1d02d 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 c4af3e90135cbd30eae42d5d3f0d2a44fbe86af6..c0a571e4f53090966ed08844b4a1d177fd845d96 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;
         }