Fix for SVACE issue. (#326) 81/191481/1
authorharish.191@samsung.com <harish.191@samsung.com>
Thu, 11 Oct 2018 09:18:35 +0000 (14:48 +0530)
committerAmit KS <amit.s12@samsung.com>
Wed, 17 Oct 2018 11:14:41 +0000 (16:44 +0530)
[CONPRO-1305] Fix for SVACE issue.

1. Add condition to stop receive negative value.
2. Check condition for thread creation successful.
3. Check return value of function.
4. Update type mismatch value assigned.

https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/pull/326
(cherry picked from commit cb27ef5e3947ffc529630e0792eff21f4d081f12)

Change-Id: I44aca78703df3fbbe61bd0772760df22fd6c3db9
Signed-off-by: Amit KS <amit.s12@samsung.com>
resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c
resource/csdk/connectivity/src/cainterfacecontroller.c
resource/csdk/connectivity/src/tcp_adapter/catcpserver.c
resource/provisioning/examples/provisioningclient.cpp
resource/provisioning/src/OCProvisioningManager.cpp
service/notification/src/provider/NSProviderScheduler.c

index f0c924d62e980bdd997c095469e063688004560f..7ecbefa8f9c4d59d9ffe97a31aba81d06280252e 100755 (executable)
@@ -1315,7 +1315,7 @@ static void CALEServerSendDataThread(void *threadData)
     uint32_t dataLen = 0;
     if (g_mtuSize > totalLength)
     {
-        length = totalLength;
+        length = (uint32_t)totalLength;
         dataLen = bleData->dataLen;
     }
     else
@@ -1616,7 +1616,7 @@ static void CALEClientSendDataThread(void *threadData)
     uint32_t dataLen = 0;
     if (g_mtuSize > totalLength)
     {
-        length = totalLength;
+        length = (uint32_t)totalLength;
         dataLen = bleData->dataLen;
     }
     else
index b72f79d51136517486317cc6f53c05165f06558c..ead1050d169d7c41ab618fa097aac17f2bb6adfa 100755 (executable)
@@ -482,7 +482,7 @@ CAResult_t CAGetNetworkInfo(CAEndpoint_t **info, uint32_t *size)
     }
 
     CAResult_t res = CA_STATUS_FAILED;
-    size_t resSize = 0;
+    uint32_t resSize = 0;
     for (uint32_t index = 0; index < g_numberOfAdapters; index++)
     {
         if (g_adapterHandler[index].GetnetInfo != NULL)
@@ -508,7 +508,7 @@ CAResult_t CAGetNetworkInfo(CAEndpoint_t **info, uint32_t *size)
         }
     }
 
-    OIC_LOG_V(DEBUG, TAG, "network info total size is %zu!", resSize);
+    OIC_LOG_V(DEBUG, TAG, "network info total size is %" PRIu32, resSize);
 
     if (resSize == 0)
     {
index 7cf9a7152ba9bd87dcfc1b2112816b0496989de7..e4dd27e2191142aa7fe9d20794d7777df8b54e9d 100644 (file)
@@ -1170,10 +1170,16 @@ void CATCPStopServer()
     CLOSE_SOCKET(ipv6s);
 #endif
 
-    close(caglobals.tcp.connectionFds[1]);
-    close(caglobals.tcp.connectionFds[0]);
-    caglobals.tcp.connectionFds[1] = OC_INVALID_SOCKET;
-    caglobals.tcp.connectionFds[0] = OC_INVALID_SOCKET;
+    if (caglobals.tcp.connectionFds[1] != OC_INVALID_SOCKET)
+    {
+       close(caglobals.tcp.connectionFds[1]);
+       caglobals.tcp.connectionFds[1] = OC_INVALID_SOCKET;
+    }
+    if (caglobals.tcp.connectionFds[0] != OC_INVALID_SOCKET)
+    {
+       close(caglobals.tcp.connectionFds[0]);
+       caglobals.tcp.connectionFds[0] = OC_INVALID_SOCKET;
+    }
 #ifndef __TIZENRT__
     if (caglobals.tcp.shutdownFds[1] != OC_INVALID_SOCKET)
     {
index 9c20bddeb192fccd118e5d130af83cf9e3e4024d..880ae8376973d22b49c0fc5fe711de9e8ed1bbc2 100644 (file)
@@ -892,7 +892,7 @@ static int saveTrustCert(void)
             }
             rewind(fp);
             fsize = fread(trustCertChainArray.data, 1, fsize, fp);
-            if(0 == fsize)
+            if (0 == fsize && ferror(fp))
             {
                 OIC_LOG(ERROR,TAG,"Read error");
             }
index e83b332fea516be68195bc1e7ede2546d74d5548..1ce0ccaa72239b9139725ada605f72c6e8f99a78 100644 (file)
@@ -459,6 +459,7 @@ namespace OC
             }
             else
             {
+               delete context;
                 oclog() <<"Can not convert struuid to uuid";
             }
         }
index 2dddff0bcf2cc1f12b3174e1d49874be2263030b..7817ce6ee4ef050f8c764505c047e3c6c809c70c 100755 (executable)
@@ -149,7 +149,11 @@ bool NSStartScheduler()
                 ns_pthread_create(&NSThread[i], NSTopicSchedule, NULL, "IoT_NS_TopicSchedule",
                                   CONFIG_IOTIVITY_NS_TOPICSCHED_PTHREAD_STACKSIZE);
 #else
-                pthread_create(&NSThread[i], NULL, NSTopicSchedule, NULL);
+                if (pthread_create(&NSThread[i], NULL, NSTopicSchedule, NULL) != 0)
+                {
+                   NS_LOG(ERROR, "Unable to create the NSThread");
+                   return false;
+                }
 #endif
             }
                 break;