prevent defects resolved (removed not useful code)
authorjw1103.kim <jw1103.kim@samsung.com>
Tue, 19 May 2015 13:52:06 +0000 (22:52 +0900)
committerErich Keane <erich.keane@intel.com>
Thu, 21 May 2015 00:16:05 +0000 (00:16 +0000)
dereferencing freed pointer, comparing an array to null

Change-Id: I9b9e49d39df8d4220c183bec0f8617b198a484a7
Signed-off-by: jw1103.kim <jw1103.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1038
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Erich Keane <erich.keane@intel.com>
resource/csdk/connectivity/src/ip_adapter/android/caipnwmonitor.c
resource/csdk/connectivity/src/ip_adapter/caipadapter.c
resource/csdk/connectivity/src/ip_adapter/caipserver.c
resource/csdk/connectivity/src/ip_adapter/linux/caipnwmonitor.c
resource/csdk/connectivity/src/ip_adapter/tizen/caipnwmonitor.c

index 987504d..4272e65 100644 (file)
@@ -703,14 +703,9 @@ CAResult_t CAIPGetInterfaceSubnetMask(const char *ipAddress, char **subnetMask)
 
         if (strncmp(info->ipAddress, ipAddress, strlen(ipAddress)) == 0)
         {
-            if (!info->subnetMask)
-            {
-                OIC_LOG(ERROR, IP_MONITOR_TAG,
-                        "CAIPGetInterfaceSubnetMask subnetmask is null");
-            }
             OIC_LOG_V(DEBUG, IP_MONITOR_TAG,
                       "CAIPGetInterfaceSubnetMask subnetmask is %s", info->subnetMask);
-            *subnetMask = info->subnetMask ? OICStrdup(info->subnetMask) : NULL;
+            *subnetMask = OICStrdup(info->subnetMask);
             break;
         }
     }
index faf147a..bd9af23 100644 (file)
@@ -421,7 +421,7 @@ CAResult_t CAStartIP()
     for (listIndex = 0; listIndex < listLength; listIndex++)
     {
         CANetInfo_t *netInfo = (CANetInfo_t *) u_arraylist_get(netInterfaceList, listIndex);
-        if (!netInfo || !netInfo->ipAddress)
+        if (!netInfo)
         {
             continue;
         }
@@ -479,7 +479,7 @@ CAResult_t CAStartIPListeningServer()
     {
 
         CANetInfo_t *netInfo = (CANetInfo_t *) u_arraylist_get(netInterfaceList, listIndex);
-        if (!netInfo || !netInfo->ipAddress)
+        if (!netInfo)
         {
             continue;
         }
@@ -617,7 +617,7 @@ CAResult_t CAGetIPInterfaceInformation(CALocalConnectivity_t **info, uint32_t *s
     for (listIndex = 0; listIndex < listLength; listIndex++)
     {
         CANetInfo_t *netInfo = (CANetInfo_t *) u_arraylist_get(netInterfaceList, listIndex);
-        if (!netInfo || !netInfo->ipAddress)
+        if (!netInfo)
         {
             continue;
         }
index f3ac991..38f164c 100644 (file)
@@ -347,10 +347,6 @@ static CAResult_t CACreateSocket(int *socketFD, const char *localIp, uint16_t *p
     {
         sockAddr.sin_addr.s_addr = inet_addr(localIp);
     }
-    else
-    {
-        sockAddr.sin_addr.s_addr = htonl(INADDR_ANY);
-    }
 
     int16_t i = 0;
     bool isBound = false;
@@ -810,8 +806,7 @@ CAResult_t CAIPStopServer(const char *interfaceAddress)
                 }
                 CACloseSocket(info->socketFd);
                 OICFree(info);
-                OIC_LOG_V(DEBUG, IP_SERVER_TAG,
-                          "Multicast server is stopped successfully on IF [%s]", info->ifAddr);
+                OIC_LOG(DEBUG, IP_SERVER_TAG, "Multicast server is stopped successfully.");
                 // Reduce list length by 1 as we removed one element.
                 listLength--;
             }
@@ -828,8 +823,7 @@ CAResult_t CAIPStopServer(const char *interfaceAddress)
             {
                 CACloseSocket(info->socketFd);
                 OICFree(info);
-                OIC_LOG_V(DEBUG, IP_SERVER_TAG,
-                          "Unicast server is stopped successfully on IF [%s]", info->ifAddr);
+                OIC_LOG(DEBUG, IP_SERVER_TAG, "Unicast server is stopped successfully.");
                 // Reduce list length by 1 as we removed one element.
                 listLength--;
             }
index 459b812..c077580 100644 (file)
@@ -611,14 +611,9 @@ CAResult_t CAIPGetInterfaceSubnetMask(const char *ipAddress, char **subnetMask)
 
         if (strncmp(info->ipAddress, ipAddress, strlen(ipAddress)) == 0)
         {
-            if (!info->subnetMask)
-            {
-                OIC_LOG(ERROR, IP_MONITOR_TAG,
-                        "CAIPGetInterfaceSubnetMask subnetmask is null");
-            }
             OIC_LOG_V(DEBUG, IP_MONITOR_TAG,
                       "CAIPGetInterfaceSubnetMask subnetmask is %s", info->subnetMask);
-            *subnetMask = info->subnetMask ? OICStrdup(info->subnetMask) : NULL;
+            *subnetMask = OICStrdup(info->subnetMask);
             break;
         }
     }
index 867fafe..1a46cd8 100644 (file)
@@ -593,14 +593,9 @@ CAResult_t CAIPGetInterfaceSubnetMask(const char *ipAddress, char **subnetMask)
 
         if (strncmp(info->ipAddress, ipAddress, strlen(ipAddress)) == 0)
         {
-            if (!info->subnetMask)
-            {
-                OIC_LOG(ERROR, IP_MONITOR_TAG,
-                        "CAIPGetInterfaceSubnetMask subnetmask is null");
-            }
             OIC_LOG_V(DEBUG, IP_MONITOR_TAG,
                       "CAIPGetInterfaceSubnetMask subnetmask is %s", info->subnetMask);
-            *subnetMask = info->subnetMask ? OICStrdup(info->subnetMask) : NULL;
+            *subnetMask = OICStrdup(info->subnetMask);
             break;
         }
     }