Update snapshot(2018-01-04) 65/165865/1 accepted/tizen/4.0/unified/20180111.051014 submit/tizen_4.0/20180105.072743
authorHongkuk, Son <hongkuk.son@samsung.com>
Thu, 4 Jan 2018 10:42:08 +0000 (19:42 +0900)
committerHongkuk, Son <hongkuk.son@samsung.com>
Thu, 4 Jan 2018 10:44:04 +0000 (19:44 +0900)
Signed-off-by: Hongkuk, Son <hongkuk.son@samsung.com>
Change-Id: I4f4ee78d3bd2474fcbabc5a2abd41b9ea10b55d2

29 files changed:
extlibs/mbedtls/CVE-2017-14032.patch [new file with mode: 0644]
extlibs/mbedtls/SConscript
packaging/iotivity.spec
packaging/snapshot_history.txt
resource/csdk/connectivity/src/adapter_util/ca_adapter_net_ssl.c
resource/csdk/connectivity/src/bt_le_adapter/android/caleclient.c
resource/csdk/connectivity/src/bt_le_adapter/android/calestate.c
resource/csdk/connectivity/src/cainterfacecontroller.c
resource/csdk/connectivity/src/camessagehandler.c
resource/csdk/connectivity/src/ip_adapter/caipadapter.c
resource/csdk/connectivity/src/tcp_adapter/catcpserver.c
resource/csdk/security/src/credresource.c
resource/csdk/stack/include/internal/ocserverrequest.h
resource/csdk/stack/include/internal/ocstackinternal.h
resource/csdk/stack/include/ocstackconfig.h
resource/csdk/stack/include/octypes.h
resource/csdk/stack/samples/linux/SimpleClientServer/occlientcoll.cpp
resource/csdk/stack/src/ocobserve.c
resource/csdk/stack/src/ocresource.c
resource/csdk/stack/src/ocserverrequest.c
resource/csdk/stack/src/ocstack.c
resource/include/InProcClientWrapper.h
resource/provisioning/src/OCProvisioningManager.cpp
resource/src/InProcClientWrapper.cpp
resource/unittests/OCPlatformTest.cpp
service/easy-setup/sampleapp/enrollee/linux/enrolleewifi.c
tools/tizen/iotivity-vd-tv-es-tizen30.spec
tools/tizen/iotivity-vd-tv-tizen30.spec
tools/tizen/iotivity.spec

diff --git a/extlibs/mbedtls/CVE-2017-14032.patch b/extlibs/mbedtls/CVE-2017-14032.patch
new file mode 100644 (file)
index 0000000..4384469
--- /dev/null
@@ -0,0 +1,161 @@
+From e8bd647d8271174d3737dcf68086126b73a73df6 Mon Sep 17 00:00:00 2001
+From: Oleksii Beketov <ol.beketov@samsung.com>
+Date: Mon, 18 Dec 2017 15:23:28 +0200
+Subject: [PATCH] CVE-2017-14032
+
+Signed-off-by: Oleksii Beketov <ol.beketov@samsung.com>
+---
+ include/mbedtls/error.h    |  2 +-
+ include/mbedtls/ssl.h      |  2 +-
+ include/mbedtls/x509.h     |  1 +
+ include/mbedtls/x509_crt.h |  8 +++++++-
+ library/error.c            |  2 ++
+ library/x509_crt.c         | 30 ++++++++++++++++++++++--------
+ 6 files changed, 34 insertions(+), 11 deletions(-)
+
+diff --git a/include/mbedtls/error.h b/include/mbedtls/error.h
+index 5e549f6..31591e2 100644
+--- a/include/mbedtls/error.h
++++ b/include/mbedtls/error.h
+@@ -71,7 +71,7 @@
+  * Name      ID  Nr of Errors
+  * PEM       1   9
+  * PKCS#12   1   4 (Started from top)
+- * X509      2   19
++ * X509      2   20
+  * PKCS5     2   4 (Started from top)
+  * DHM       3   9
+  * PK        3   14 (Started from top)
+diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h
+index 495e02c..4f171e0 100644
+--- a/include/mbedtls/ssl.h
++++ b/include/mbedtls/ssl.h
+@@ -1042,7 +1042,7 @@ void mbedtls_ssl_conf_authmode( mbedtls_ssl_config *conf, int authmode );
+  *
+  *                 If set, the verify callback is called for each
+  *                 certificate in the chain. For implementation
+- *                 information, please see \c x509parse_verify()
++ *                 information, please see \c mbedtls_x509_crt_verify()
+  *
+  * \param conf     SSL configuration
+  * \param f_vrfy   verification function
+diff --git a/include/mbedtls/x509.h b/include/mbedtls/x509.h
+index f219bf1..128eade 100644
+--- a/include/mbedtls/x509.h
++++ b/include/mbedtls/x509.h
+@@ -76,6 +76,7 @@
+ #define MBEDTLS_ERR_X509_ALLOC_FAILED                     -0x2880  /**< Allocation of memory failed. */
+ #define MBEDTLS_ERR_X509_FILE_IO_ERROR                    -0x2900  /**< Read/write of file failed. */
+ #define MBEDTLS_ERR_X509_BUFFER_TOO_SMALL                 -0x2980  /**< Destination buffer is too small. */
++#define MBEDTLS_ERR_X509_FATAL_ERROR                      -0x3000  /**< A fatal error occured, eg the chain is too long or the vrfy callback failed. */
+ /* \} name */
+ /**
+diff --git a/include/mbedtls/x509_crt.h b/include/mbedtls/x509_crt.h
+index 383e484..fd20336 100644
+--- a/include/mbedtls/x509_crt.h
++++ b/include/mbedtls/x509_crt.h
+@@ -267,7 +267,13 @@ int mbedtls_x509_crt_verify_info( char *buf, size_t size, const char *prefix,
+  *
+  *                 All flags left after returning from the callback
+  *                 are also returned to the application. The function should
+- *                 return 0 for anything but a fatal error.
++ *                 return 0 for anything (including invalid certificates)
++ *                 other than fatal error, as a non-zero return code
++ *                 immediately aborts the verification process. For fatal
++ *                 errors, a specific error code should be used (different
++ *                 from MBEDTLS_ERR_X509_CERT_VERIFY_FAILED which should not
++ *                 be returned at this point), or MBEDTLS_ERR_X509_FATAL_ERROR
++ *                 can be used if no better code is available.
+  *
+  * \note           In case verification failed, the results can be displayed
+  *                 using \c mbedtls_x509_crt_verify_info()
+diff --git a/library/error.c b/library/error.c
+index dd2db0c..db42381 100644
+--- a/library/error.c
++++ b/library/error.c
+@@ -480,6 +480,8 @@ void mbedtls_strerror( int ret, char *buf, size_t buflen )
+             mbedtls_snprintf( buf, buflen, "X509 - Read/write of file failed" );
+         if( use_ret == -(MBEDTLS_ERR_X509_BUFFER_TOO_SMALL) )
+             mbedtls_snprintf( buf, buflen, "X509 - Destination buffer is too small" );
++        if( use_ret == -(MBEDTLS_ERR_X509_FATAL_ERROR) )
++            mbedtls_snprintf( buf, buflen, "X509 - A fatal error occured, eg the chain is too long or the vrfy callback failed" );
+ #endif /* MBEDTLS_X509_USE_C || MBEDTLS_X509_CREATE_C */
+         // END generated code
+diff --git a/library/x509_crt.c b/library/x509_crt.c
+index 234f145..1f31a6b 100644
+--- a/library/x509_crt.c
++++ b/library/x509_crt.c
+@@ -2055,8 +2055,8 @@ static int x509_crt_verify_child(
+     /* path_cnt is 0 for the first intermediate CA */
+     if( 1 + path_cnt > MBEDTLS_X509_MAX_INTERMEDIATE_CA )
+     {
+-        *flags |= MBEDTLS_X509_BADCERT_NOT_TRUSTED;
+-        return( MBEDTLS_ERR_X509_CERT_VERIFY_FAILED );
++        /* return immediately as the goal is to avoid unbounded recursion */
++        return( MBEDTLS_ERR_X509_FATAL_ERROR );
+     }
+     if( mbedtls_x509_time_is_past( &child->valid_to ) )
+@@ -2200,11 +2200,14 @@ int mbedtls_x509_crt_verify_with_profile( mbedtls_x509_crt *crt,
+     mbedtls_x509_sequence *cur = NULL;
+     mbedtls_pk_type_t pk_type;
+-    if( profile == NULL )
+-        return( MBEDTLS_ERR_X509_BAD_INPUT_DATA );
+-
+     *flags = 0;
++    if( profile == NULL )
++    {
++        ret = MBEDTLS_ERR_X509_BAD_INPUT_DATA;
++        goto exit;
++    }
++
+     if( cn != NULL )
+     {
+         name = &crt->subject;
+@@ -2278,7 +2281,7 @@ int mbedtls_x509_crt_verify_with_profile( mbedtls_x509_crt *crt,
+         ret = x509_crt_verify_top( crt, parent, ca_crl, profile,
+                                    pathlen, selfsigned, flags, f_vrfy, p_vrfy );
+         if( ret != 0 )
+-            return( ret );
++            goto exit;
+     }
+     else
+     {
+@@ -2293,17 +2296,28 @@ int mbedtls_x509_crt_verify_with_profile( mbedtls_x509_crt *crt,
+             ret = x509_crt_verify_child( crt, parent, trust_ca, ca_crl, profile,
+                                          pathlen, selfsigned, flags, f_vrfy, p_vrfy );
+             if( ret != 0 )
+-                return( ret );
++                goto exit;
+         }
+         else
+         {
+             ret = x509_crt_verify_top( crt, trust_ca, ca_crl, profile,
+                                        pathlen, selfsigned, flags, f_vrfy, p_vrfy );
+             if( ret != 0 )
+-                return( ret );
++                goto exit;
+         }
+     }
++exit:
++    /* prevent misuse of the vrfy callback */
++    if( ret == MBEDTLS_ERR_X509_CERT_VERIFY_FAILED )
++        ret = MBEDTLS_ERR_X509_FATAL_ERROR;
++
++    if( ret != 0 )
++    {
++        *flags = (uint32_t) -1;
++        return( ret );
++    }
++
+     if( *flags != 0 )
+         return( MBEDTLS_ERR_X509_CERT_VERIFY_FAILED );
+-- 
+1.9.1
+
index cfcec9d..c385f30 100644 (file)
@@ -65,7 +65,7 @@ os.chdir(mbedtls_dir)
 
 # Apply ocf patch on git revision
 if os.path.exists('.git/HEAD'):
-    cmd = 'git checkout development && git reset --hard ' + mbedtls_revision + ' && git apply --whitespace=fix ../ocf.patch'
+    cmd = 'git checkout development && git reset --hard ' + mbedtls_revision + ' && git apply --whitespace=fix ../ocf.patch' + ' && git apply --whitespace=fix ../CVE-2017-14032.patch'
     os.system(cmd)
 else:
     print 'mbedtls: Assume ocf.patch (TLS_ECDH_ANON_WITH_AES_128_CBC_SHA256) was applied in %s' % mbedtls_dir
index e7aa8bf..54d09d1 100755 (executable)
@@ -261,7 +261,6 @@ cp ./resource/csdk/security/include/internal/*.h %{buildroot}%{_includedir}/
 cp ./resource/csdk/security/provisioning/include/oxm/*.h %{buildroot}%{_includedir}
 cp ./resource/csdk/security/provisioning/include/internal/*.h %{buildroot}%{_includedir}
 cp ./resource/csdk/security/provisioning/include/*.h %{buildroot}%{_includedir}
-cp ./resource/csdk/security/provisioning/sample/oic_svr_db_server_justworks.dat %{buildroot}%{_libdir}/oic_svr_db_server.dat
 cp out/%{TARGET_OS}/%{TARGET_ARCH}/%{build_mode}/resource/csdk/security/provisioning/sample/sampleserver_justworks %{ex_install_dir}/provision-sample/
 cp ./resource/csdk/security/provisioning/sample/oic_svr_db_server_justworks.dat %{ex_install_dir}/provision-sample/
 cp out/%{TARGET_OS}/%{TARGET_ARCH}/%{build_mode}/resource/csdk/security/provisioning/sample/sampleserver_randompin %{ex_install_dir}/provision-sample/
@@ -310,7 +309,6 @@ rm -rfv out %{buildroot}/out %{buildroot}/${HOME} ||:
 %{_libdir}/libmbedtls.so
 %{_libdir}/libocpmapi.so
 %{_libdir}/libocprovision.so
-%{_libdir}/oic_svr_db_server.dat
 %endif
 
 %files service
index cae0a64..130ee09 100755 (executable)
@@ -1,3 +1,9 @@
+http://suprem.sec.samsung.net/jira/browse/CONPRO-1180
+
+commit_info_2018-01-04.txt
+
+commit_id: a0593f6d08f74d736d39523f93b16077a5f6e659
+----------------------------------------------------------------------------------------------------------------------------------
 http://suprem.sec.samsung.net/jira/browse/CONPRO-1176
 
 [CONPRO-1176] iotivity crash during CAReceiveMessage
index b953c35..7be3576 100644 (file)
@@ -2383,15 +2383,14 @@ CAResult_t CAdecryptSsl(const CASecureEndpoint_t *sep, uint8_t *data, uint32_t d
                                                  sizeof(sep->endpoint.addr));
             ret = mbedtls_ssl_handshake_step(&peer->ssl);
         }
-        if (MBEDTLS_SSL_IS_CLIENT == peer->ssl.conf->endpoint)
+        uint32_t flags = mbedtls_ssl_get_verify_result(&peer->ssl);
+        if (0 != flags &&
+           ((MBEDTLS_SSL_IS_CLIENT == peer->ssl.conf->endpoint) ||
+            (MBEDTLS_SSL_IS_SERVER == peer->ssl.conf->endpoint && MBEDTLS_X509_BADCERT_MISSING != flags)))
         {
-            uint32_t flags = mbedtls_ssl_get_verify_result(&peer->ssl);
-            if (0 != flags)
-            {
-                OIC_LOG_BUFFER(ERROR, NET_SSL_TAG, (const uint8_t *) &flags, sizeof(flags));
-                SSL_CHECK_FAIL(peer, flags, "Cert verification failed", 1,
-                                                         CA_STATUS_FAILED, GetAlertCode(flags));
-            }
+            OIC_LOG_BUFFER(ERROR, NET_SSL_TAG, (const uint8_t *) &flags, sizeof(flags));
+            SSL_CHECK_FAIL(peer, flags, "Cert verification failed", 1,
+                                                     CA_STATUS_FAILED, GetAlertCode(flags));
         }
         SSL_CHECK_FAIL(peer, ret, "Handshake error", 1, CA_STATUS_FAILED, MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE);
         if (MBEDTLS_SSL_CLIENT_CHANGE_CIPHER_SPEC == peer->ssl.state)
index 2ac416c..87a2d6e 100644 (file)
@@ -975,7 +975,8 @@ CAResult_t CALEClientIsThereScannedDevices(JNIEnv *env, const char* address)
 CAResult_t CALEClientSendUnicastMessageImpl(const char* address, const uint8_t* data,
                                             const uint32_t dataLen)
 {
-    OIC_LOG_V(INFO, TAG, "CALEClientSendUnicastMessageImpl, address: %s, data: %p", address,
+    OIC_LOG(INFO, TAG, "CALEClientSendUnicastMessageImpl in");
+    OIC_LOG_V(DEBUG, TAG, "CALEClientSendUnicastMessageImpl, address: %s, data: %p", address,
               data);
     VERIFY_NON_NULL(address, TAG, "address is null");
 
@@ -4918,7 +4919,7 @@ Java_org_iotivity_ca_CaLeClientInterface_caLeGattConnectionStateChangeCallback(J
         CACheckJNIException(env);
         goto error_exit;
     }
-    OIC_LOG_V(INFO, TAG, "CALeGattConnectionStateChangeCallback - address [%s]", address);
+    OIC_LOG_V(DEBUG, TAG, "CALeGattConnectionStateChangeCallback - address [%s]", address);
 
     if (state_connected == newstate)
     {
index c1b7101..73658ce 100644 (file)
@@ -69,7 +69,7 @@ CAResult_t CALEUpdateDeviceState(const char* address,
             default:
                 break;
         }
-        OIC_LOG_V(INFO, TAG, "update state - addr: %s, conn: %d, send: %d, ACFlag: %d, mtu: %d",
+        OIC_LOG_V(DEBUG, TAG, "update state - addr: %s, conn: %d, send: %d, ACFlag: %d, mtu: %d",
                   curState->address, curState->connectedState, curState->sendState,
                   curState->autoConnectFlag, curState->mtuSize);
     }
@@ -105,7 +105,7 @@ CAResult_t CALEUpdateDeviceState(const char* address,
             default:
                 break;
         }
-        OIC_LOG_V(INFO, TAG, "add a new state to List - addr : %s, "
+        OIC_LOG_V(DEBUG, TAG, "add a new state to List - addr : %s, "
                   "conn : %d, send : %d, ACFlag : %d",
                   newstate->address, newstate->connectedState, newstate->sendState,
                   newstate->autoConnectFlag);
@@ -425,7 +425,7 @@ CAResult_t CALESetMtuSize(const char* address, uint16_t mtuSize,
         }
 
         curState->mtuSize = mtuSize;
-        OIC_LOG_V(INFO, TAG, "update state - addr: %s, mtu: %d",
+        OIC_LOG_V(DEBUG, TAG, "update state - addr: %s, mtu: %d",
                   curState->address, curState->mtuSize);
     }
     else
@@ -452,7 +452,7 @@ uint16_t CALEGetMtuSize(const char* address, u_arraylist_t *deviceList, oc_mutex
             return CA_DEFAULT_BLE_MTU_SIZE;
         }
 
-        OIC_LOG_V(INFO, TAG, "state - addr: %s, mtu: %d",
+        OIC_LOG_V(DEBUG, TAG, "state - addr: %s, mtu: %d",
                   curState->address, curState->mtuSize);
         oc_mutex_unlock(deviceListMutex);
         return curState->mtuSize;
index c892289..b72f79d 100755 (executable)
@@ -336,8 +336,8 @@ void CAInitializeAdapters(ca_thread_pool_t handle, CATransportAdapter_t transpor
     if ((transportType & CA_ADAPTER_IP) || (CA_DEFAULT_ADAPTER == transportType)
             || (transportType == CA_ALL_ADAPTERS))
     {
-        CAInitializeIP(CARegisterCallback, CAReceivedPacketCallback, CAAdapterChangedCallback,
-                       CAAdapterErrorHandleCallback, handle);
+        CAInitializeIP(CARegisterCallback, (CANetworkPacketReceivedCallback)CAReceivedPacketCallback, CAAdapterChangedCallback,
+                       (CAErrorHandleCallback)CAAdapterErrorHandleCallback, handle);
     }
 #endif /* IP_ADAPTER */
 
@@ -354,8 +354,8 @@ void CAInitializeAdapters(ca_thread_pool_t handle, CATransportAdapter_t transpor
     if ((transportType & CA_ADAPTER_GATT_BTLE) || (CA_DEFAULT_ADAPTER == transportType)
             || (transportType == CA_ALL_ADAPTERS))
     {
-        CAInitializeLE(CARegisterCallback, CAReceivedPacketCallback, CAAdapterChangedCallback,
-                       CAConnectionChangedCallback, CAAdapterErrorHandleCallback, handle);
+        CAInitializeLE(CARegisterCallback, (CANetworkPacketReceivedCallback)CAReceivedPacketCallback, CAAdapterChangedCallback,
+                       CAConnectionChangedCallback, (CAErrorHandleCallback)CAAdapterErrorHandleCallback, handle);
     }
 #endif /* LE_ADAPTER */
 
index d9be889..ebd322b 100755 (executable)
@@ -51,6 +51,8 @@
 #define SINGLE_HANDLE
 #define MAX_THREAD_POOL_SIZE    20
 
+#define UNUSED(x) (void)(x)
+
 // thread pool handle
 static ca_thread_pool_t g_threadPoolHandle = NULL;
 
@@ -895,8 +897,7 @@ static void CAAdapterStateChangedCallback(CATransportAdapter_t transportType, bo
 
 static bool CAClearQueueEndpointDataContext(void *data, uint32_t size, void *ctx)
 {
-    (void)size;
-
+    UNUSED(size);
     if (NULL == data || NULL == ctx)
     {
         return false;
@@ -1174,8 +1175,8 @@ void CASetNetworkMonitorCallback(CANetworkMonitorCallback nwMonitorHandler)
 
 CAResult_t CAInitializeMessageHandler(CATransportAdapter_t transportType)
 {
-    CASetPacketReceivedCallback(CAReceivedPacketCallback);
-    CASetErrorHandleCallback(CAErrorHandler);
+    CASetPacketReceivedCallback((CANetworkPacketReceivedCallback)CAReceivedPacketCallback);
+    CASetErrorHandleCallback((CAErrorHandleCallback)CAErrorHandler);
 
 #ifndef SINGLE_THREAD
     // create thread pool
@@ -1608,7 +1609,7 @@ static void CALogPDUInfo(const CAData_t *data, const coap_pdu_t *pdu)
     if (NULL != data->remoteEndpoint)
     {
         CALogAdapterTypeInfo(data->remoteEndpoint->adapter);
-        OIC_LOG_V(INFO, ANALYZER_TAG, "Address = [%s]:[%d]", data->remoteEndpoint->addr,
+        OIC_LOG_V(DEBUG, ANALYZER_TAG, "Address = [%s]:[%d]", data->remoteEndpoint->addr,
                   data->remoteEndpoint->port);
     }
 
index d6b1b89..59d4449 100644 (file)
@@ -274,7 +274,7 @@ CAResult_t CAInitializeIP(CARegisterConnectivityCallback registerCallback,
     caglobals.ip.threadpool = handle;
 
     CAIPSetErrorHandler(CAIPErrorHandler);
-    CAIPSetPacketReceiveCallback(CAIPPacketReceivedCB);
+    CAIPSetPacketReceiveCallback((CAIPPacketReceivedCallback)CAIPPacketReceivedCB);
 
 #ifdef __WITH_DTLS__
     CAsetSslAdapterCallbacks(CAIPPacketReceivedCB, CAIPPacketSendCB, CA_ADAPTER_IP);
index 7741e68..7136fe0 100644 (file)
 static ca_thread_pool_t g_threadPool = NULL;
 
 /**
- * An unique identifier of receive thread.
- */
-static uint32_t g_recvThreadId = 0;
-
-/**
  * Mutex to synchronize device object list.
  */
 static oc_mutex g_mutexObjectList = NULL;
@@ -980,14 +975,13 @@ CAResult_t CATCPStartServer(const ca_thread_pool_t threadPool)
 
     CAResult_t res = CA_STATUS_OK;
 #ifndef __TIZENRT__
-    res = ca_thread_pool_add_task(g_threadPool, CAReceiveHandler, NULL, &g_recvThreadId);
+    res = ca_thread_pool_add_task(g_threadPool, CAReceiveHandler, NULL, NULL);
 #else
-    res = ca_thread_pool_add_task(g_threadPool, CAReceiveHandler, NULL, &g_recvThreadId,
+    res = ca_thread_pool_add_task(g_threadPool, CAReceiveHandler, NULL, NULL,
                                  "IoT_TCPReceive", CONFIG_IOTIVITY_TCPRECEIVE_PTHREAD_STACKSIZE);
 #endif
     if (CA_STATUS_OK != res)
     {
-        g_recvThreadId = 0;
         oc_mutex_unlock(g_mutexObjectList);
         OIC_LOG(ERROR, TAG, "thread_pool_add_task failed");
         CATCPStopServer();
@@ -1014,6 +1008,14 @@ void CATCPStopServer()
     // set terminate flag.
     caglobals.tcp.terminate = true;
 
+#ifdef __TIZENRT__
+    if (caglobals.tcp.started)
+    {
+        oc_cond_wait(g_condObjectList, g_mutexObjectList);
+        caglobals.tcp.started = false;
+    }
+#endif
+
     // close accept socket.
 #ifndef __WITH_TLS__
     CLOSE_SOCKET(ipv4);
@@ -1034,25 +1036,17 @@ void CATCPStopServer()
         caglobals.tcp.shutdownFds[1] = OC_INVALID_SOCKET;
         // receive thread will stop immediately
     }
-#endif
     if (caglobals.tcp.started)
     {
         oc_cond_wait(g_condObjectList, g_mutexObjectList);
         caglobals.tcp.started = false;
     }
-#ifndef __TIZENRT__
     if (caglobals.tcp.shutdownFds[0] != OC_INVALID_SOCKET)
     {
         close(caglobals.tcp.shutdownFds[0]);
         caglobals.tcp.shutdownFds[0] = OC_INVALID_SOCKET;
     }
 #endif
-    CAResult_t res = ca_thread_pool_remove_task(g_threadPool, g_recvThreadId);
-    if (CA_STATUS_OK != res)
-    {
-        OIC_LOG(ERROR, TAG, "ca_thread_pool_remove_task failed");
-    }
-    g_recvThreadId = 0;
     oc_mutex_unlock(g_mutexObjectList);
 
     CATCPDisconnectAll();
index d4a7c61..585d48b 100644 (file)
@@ -59,6 +59,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 #endif
+#define UNUSED(x) (void)(x)
 
 #define TAG  "OIC_SRM_CREDL"
 
@@ -100,7 +101,9 @@ typedef enum CredCompareResult{
  */
 static bool CheckSubjectOfCertificate(OicSecCred_t* cred, OicUuid_t deviceID)
 {
+    UNUSED(deviceID);
     OicUuid_t emptyUuid = {.id={0}};
+    UNUSED(emptyUuid);
     OIC_LOG(DEBUG, TAG, "IN CheckSubjectOfCertificate");
     VERIFY_NON_NULL(TAG, cred, ERROR);
 
index 1de99ea..565c6e1 100644 (file)
@@ -91,7 +91,7 @@ typedef struct OCServerRequest
     uint8_t numRcvdVendorSpecificHeaderOptions;
 
     /** An Array  of received vendor specific header options.*/
-    OCHeaderOption rcvdVendorSpecificHeaderOptions[MAX_HEADER_OPTIONS];
+    OCHeaderOption *rcvdVendorSpecificHeaderOptions;
 
     /** Request to complete.*/
     uint8_t requestComplete;
index 93b0427..4885b56 100644 (file)
@@ -99,7 +99,7 @@ typedef struct
     uint8_t numRcvdVendorSpecificHeaderOptions;
 
     /** Array of received vendor specific header option .*/
-    OCHeaderOption rcvdVendorSpecificHeaderOptions[MAX_HEADER_OPTIONS];
+    OCHeaderOption *rcvdVendorSpecificHeaderOptions;
 
     /** Remote end-point address **/
     OCDevAddr devAddr;
index 935a8ca..ee4ffe3 100644 (file)
@@ -89,9 +89,7 @@
 #if defined(ARDUINO) || defined(__TIZENRT__)
 #define MAX_HEADER_OPTIONS (2)
 #else
-//#define MAX_HEADER_OPTIONS (50)
-// For CONPRO-1172
-#define MAX_HEADER_OPTIONS (5)
+#define MAX_HEADER_OPTIONS (50)
 #endif
 
 /**
index f1ed8b1..1f0c453 100644 (file)
@@ -1542,7 +1542,7 @@ typedef struct
     uint8_t numRcvdVendorSpecificHeaderOptions;
 
     /** An array of the received vendor specific header options.*/
-    OCHeaderOption rcvdVendorSpecificHeaderOptions[MAX_HEADER_OPTIONS];
+    OCHeaderOption *rcvdVendorSpecificHeaderOptions;
 } OCClientResponse;
 
 /**
index 5063181..e17b1fa 100644 (file)
@@ -95,7 +95,7 @@ testToTextMap queryInterface[] = {
         {"?if=oic.if.b", TEST_PUT_BATCH},
         {"?if=oic.if.ll", TEST_PUT_LINK_LIST},
         {"", TEST_GET_EMPTY},
-        {NULL, TEST_GET_NULL},
+        {NULL, TEST_GET_NULL}
 };
 
 
index db055ba..4fa079b 100644 (file)
@@ -223,7 +223,9 @@ static OCStackResult SendObserveNotification(ResourceObserver *observer,
             {
                 ehResult = observer->resource->entityHandler(OC_REQUEST_FLAG, &ehRequest,
                                     observer->resource->entityHandlerCallbackParam);
-                if (ehResult == OC_EH_ERROR)
+
+                // Clear server request on error case
+                if (!OCResultToSuccess(EntityHandlerCodeToOCStackCode(ehResult)))
                 {
                     FindAndDeleteServerRequest(request);
                 }
@@ -308,6 +310,11 @@ OCStackResult SendAllObserverNotification (OCMethod method, OCResource *resPtr,
                         OICStrcpy(ehResponse.resourceUri, sizeof(ehResponse.resourceUri),
                                 resourceObserver->resUri);
                         result = OCDoResponse(&ehResponse);
+                        if (result != OC_STACK_OK)
+                        {
+                            OIC_LOG(ERROR, TAG, "Failed to send presence notification!");
+                            FindAndDeleteServerRequest(request);
+                        }
                     }
 
                     OCPresencePayloadDestroy(presenceResBuf);
@@ -402,17 +409,18 @@ OCStackResult SendListObserverNotification (OCResource * resource,
 
                             // Increment only if OCDoResponse is successful
                             numSentNotification++;
-
-                            OICFree(ehResponse.payload);
-                            FindAndDeleteServerRequest(request);
                         }
                         else
                         {
                             OIC_LOG_V(INFO, TAG, "Error notifying observer id %d.", *obsIdList);
+                            FindAndDeleteServerRequest(request);
                         }
+
                         // Reset Observer TTL.
                         observer->TTL =
                                 GetTicks(MAX_OBSERVER_TTL_SECONDS * MILLISECONDS_PER_SECOND);
+
+                        OICFree(ehResponse.payload);
                     }
                     else
                     {
index d6ec143..050ecc6 100755 (executable)
@@ -1164,11 +1164,15 @@ HandleDefaultDeviceEntityHandler(OCServerRequest *request)
         OIC_LOG(INFO, TAG, "This is a slow resource");
         request->slowFlag = 1;
     }
-    else if(ehResult == OC_EH_ERROR)
+
+    result = EntityHandlerCodeToOCStackCode(ehResult);
+
+    // Clear server request on error case
+    if (!OCResultToSuccess(result))
     {
         FindAndDeleteServerRequest(request);
     }
-    result = EntityHandlerCodeToOCStackCode(ehResult);
+
 exit:
     OCPayloadDestroy(ehRequest.payload);
     return result;
@@ -1308,11 +1312,15 @@ HandleResourceWithEntityHandler(OCServerRequest *request,
         OIC_LOG(INFO, TAG, "This is a slow resource");
         request->slowFlag = 1;
     }
-    else if(ehResult == OC_EH_ERROR)
+
+    result = EntityHandlerCodeToOCStackCode(ehResult);
+
+    // Clear server request on error case
+    if (!OCResultToSuccess(result))
     {
         FindAndDeleteServerRequest(request);
     }
-    result = EntityHandlerCodeToOCStackCode(ehResult);
+
 exit:
     OCPayloadDestroy(ehRequest.payload);
     FreeObserver(resObs);
index 9241a5f..91d7e1c 100644 (file)
@@ -102,6 +102,7 @@ static void DeleteServerRequest(OCServerRequest * serverRequest)
     {
         LL_DELETE(serverRequestList, serverRequest);
         OICFree(serverRequest->requestToken);
+        OICFree(serverRequest->rcvdVendorSpecificHeaderOptions);
         OICFree(serverRequest);
         serverRequest = NULL;
         OIC_LOG(INFO, TAG, "Server Request Removed!!");
@@ -306,8 +307,12 @@ OCStackResult AddServerRequest (OCServerRequest ** request, uint16_t coapID,
 
     if(rcvdVendorSpecificHeaderOptions)
     {
+        serverRequest->rcvdVendorSpecificHeaderOptions =
+                    (OCHeaderOption *) OICCalloc(numRcvdVendorSpecificHeaderOptions, sizeof(OCHeaderOption));
+        VERIFY_NON_NULL(serverRequest->rcvdVendorSpecificHeaderOptions);
+
         memcpy(serverRequest->rcvdVendorSpecificHeaderOptions, rcvdVendorSpecificHeaderOptions,
-            MAX_HEADER_OPTIONS * sizeof(OCHeaderOption));
+            numRcvdVendorSpecificHeaderOptions * sizeof(OCHeaderOption));
     }
     if(payload && reqTotalSize)
     {
@@ -348,6 +353,7 @@ exit:
     if (serverRequest)
     {
         OICFree(serverRequest->requestToken);
+        OICFree(serverRequest->rcvdVendorSpecificHeaderOptions);
         OICFree(serverRequest);
         serverRequest = NULL;
     }
index f588187..8e7253f 100644 (file)
@@ -272,11 +272,11 @@ static void deleteResourceType(OCResourceType *resourceType);
 static void deleteResourceInterface(OCResourceInterface *resourceInterface);
 
 /**
- * Delete all child resources.
+ * Unbind all child resources.
  *
- * @param resourceChild Specified binded resource is deleted from parent.
+ * @param resourceChild Specified binded resource head is deleted from parent.
  */
-static void deleteResourceChild(OCChildResource *resourceChild);
+static void unbindChildResources(OCChildResource *resourceChild);
 
 /**
  * Delete all of the dynamically allocated elements that were created for the resource.
@@ -1578,13 +1578,20 @@ void OCHandleResponse(const CAEndpoint_t* endPoint, const CAResponseInfo_t* resp
                     return;
                 }
 
-                for (uint8_t i = start; i < responseInfo->info.numOptions; i++)
+                if (response.numRcvdVendorSpecificHeaderOptions > 0)
                 {
-                    if(&(responseInfo->info.options[i]))
+                    response.rcvdVendorSpecificHeaderOptions =
+                        (OCHeaderOption *) OICCalloc(response.numRcvdVendorSpecificHeaderOptions, sizeof(OCHeaderOption));
+                    if (NULL == response.rcvdVendorSpecificHeaderOptions)
                     {
-                        memcpy (&(response.rcvdVendorSpecificHeaderOptions[i-start]),
-                                &(responseInfo->info.options[i]), sizeof(OCHeaderOption));
+                        OIC_LOG(ERROR, TAG, "Failed to allocate memory for vendor header options");
+                        OCPayloadDestroy(response.payload);
+                        OICFree((void *)response.resourceUri);
+                        return;
                     }
+
+                    memcpy(response.rcvdVendorSpecificHeaderOptions, responseInfo->info.options + start,
+                        response.numRcvdVendorSpecificHeaderOptions*sizeof(OCHeaderOption));
                 }
             }
 
@@ -1678,6 +1685,7 @@ void OCHandleResponse(const CAEndpoint_t* endPoint, const CAResponseInfo_t* resp
 
             OICFree((void *)response.resourceUri);
             OCPayloadDestroy(response.payload);
+            OICFree(response.rcvdVendorSpecificHeaderOptions);
         }
         return;
     }
@@ -2195,10 +2203,20 @@ void OCHandleRequests(const CAEndpoint_t* endPoint, const CARequestInfo_t* reque
         OICFree(serverRequest.requestToken);
         return;
     }
+
     serverRequest.numRcvdVendorSpecificHeaderOptions = tempNum;
     if (serverRequest.numRcvdVendorSpecificHeaderOptions && requestInfo->info.options)
     {
-        memcpy (&(serverRequest.rcvdVendorSpecificHeaderOptions), requestInfo->info.options,
+        serverRequest.rcvdVendorSpecificHeaderOptions = (OCHeaderOption*) OICCalloc(tempNum, sizeof(OCHeaderOption));
+        if (NULL == serverRequest.rcvdVendorSpecificHeaderOptions)
+        {
+            OIC_LOG(ERROR, TAG, "Failed to allocated memory to vnd header options!");
+            OICFree(serverRequest.payload);
+            OICFree(serverRequest.requestToken);
+            return;
+        }
+
+        memcpy (serverRequest.rcvdVendorSpecificHeaderOptions, requestInfo->info.options,
             sizeof(CAHeaderOption_t)*tempNum);
     }
 
@@ -2237,6 +2255,12 @@ void OCHandleRequests(const CAEndpoint_t* endPoint, const CARequestInfo_t* reque
     {
         OIC_LOG_V(ERROR, TAG, "HandleStackRequests failed. error: %d", requestResult);
 
+        // Delete observer node if it is OBSERVE failure from app
+        if (serverRequest.observationOption == OC_OBSERVE_REGISTER)
+        {
+            DeleteObserverUsingToken(requestInfo->info.token, requestInfo->info.tokenLength);
+        }
+
         CAResponseResult_t stackResponse =
             OCToCAStackResult(requestResult, serverRequest.method);
 
@@ -2250,6 +2274,7 @@ void OCHandleRequests(const CAEndpoint_t* endPoint, const CARequestInfo_t* reque
     // The token is copied in there, and is thus still owned by this function.
     OICFree(serverRequest.payload);
     OICFree(serverRequest.requestToken);
+    OICFree(serverRequest.rcvdVendorSpecificHeaderOptions);
     OIC_LOG(INFO, TAG, "Exit OCHandleRequests");
 }
 
@@ -4666,7 +4691,7 @@ void deleteResourceElements(OCResource *resource)
     }
     if (resource->rsrcChildResourcesHead)
     {
-        deleteResourceChild(resource->rsrcChildResourcesHead);
+        unbindChildResources(resource->rsrcChildResourcesHead);
         resource->rsrcChildResourcesHead = NULL;
     }
     if (resource->rsrcAttributes)
@@ -4708,18 +4733,13 @@ void deleteResourceInterface(OCResourceInterface *resourceInterface)
     }
 }
 
-void deleteResourceChild(OCChildResource *resourceChild)
+void unbindChildResources(OCChildResource *head)
 {
     OCChildResource *next = NULL;
-    for (OCChildResource *pointer = resourceChild; pointer; pointer = next)
+    for (OCChildResource *current = head; current; current = next)
     {
-        next = pointer->next ? pointer->next : NULL;
-        if (pointer->rsrcResource)
-        {
-            deleteResourceElements(pointer->rsrcResource);
-            pointer->rsrcResource = NULL;
-        }
-        OICFree(pointer);
+        next = current->next;
+        OICFree(current);
     }
 }
 
index ff62d7b..05b1472 100644 (file)
@@ -265,8 +265,7 @@ namespace OC
         std::string assembleSetResourceUri(std::string uri, const QueryParamsMap& queryParams);
         std::string assembleSetResourceUri(std::string uri, const QueryParamsList& queryParams);
         OCPayload* assembleSetResourcePayload(const OCRepresentation& attributes);
-        OCHeaderOption* assembleHeaderOptions(OCHeaderOption options[],
-           const HeaderOptions& headerOptions);
+        OCHeaderOption* assembleHeaderOptions(const HeaderOptions& headerOptions);
         void convert(const OCDPDev_t *list, PairedDevices& dpList);
         std::thread m_listeningThread;
         bool m_threadRun;
index b05bc2a..c34b505 100644 (file)
@@ -822,11 +822,6 @@ namespace OC
             ret = context->callback(cert, depth);
         }
 
-        if (0 == depth)
-        {
-            delete context;
-        }
-
         return (OC_STACK_OK == ret)? 0 : 1;
     }
 
@@ -840,8 +835,8 @@ namespace OC
             if (OC_STACK_OK != result)
             {
                 oclog() << "OCSetPeerCertCallback() Failed";
-                return result;
             }
+            return result;
         }
 
         auto cLock = OCPlatform_impl::Instance().csdkLock().lock();
index abea511..b4a2af8 100644 (file)
@@ -648,6 +648,12 @@ namespace OC
             return OC_STACK_INVALID_PARAM;
         }
 
+        if (headerOptions.size() > MAX_HEADER_OPTIONS)
+        {
+            oclog() << "ListenForMQTopic: Header options are more than MAX_HEADER_OPTIONS" << std::flush;
+            return OC_STACK_INVALID_PARAM;
+        }
+
         ClientCallbackContext::MQTopicContext* context =
             new ClientCallbackContext::MQTopicContext(callback, shared_from_this());
         OCCallbackData cbdata;
@@ -662,7 +668,7 @@ namespace OC
         if (cLock)
         {
             std::lock_guard<std::recursive_mutex> lock(*cLock);
-            OCHeaderOption options[MAX_HEADER_OPTIONS];
+            OCHeaderOption *options = assembleHeaderOptions(headerOptions);
             result = OCDoResource(
                                   nullptr, OC_REST_GET,
                                   uri.c_str(),
@@ -670,8 +676,9 @@ namespace OC
                                   CT_DEFAULT,
                                   static_cast<OCQualityOfService>(QoS),
                                   &cbdata,
-                                  assembleHeaderOptions(options, headerOptions),
+                                  options,
                                   headerOptions.size());
+            delete[] options;
         }
         else
         {
@@ -865,6 +872,13 @@ namespace OC
         {
             return OC_STACK_INVALID_PARAM;
         }
+
+        if (headerOptions.size() > MAX_HEADER_OPTIONS)
+        {
+            oclog() << "PutMQTopicRepresentation: Header options are more than MAX_HEADER_OPTIONS" << std::flush;
+            return OC_STACK_INVALID_PARAM;
+        }
+
         OCStackResult result;
         ClientCallbackContext::MQTopicContext* ctx =
                 new ClientCallbackContext::MQTopicContext(callback, shared_from_this());
@@ -880,7 +894,7 @@ namespace OC
         if (cLock)
         {
             std::lock_guard<std::recursive_mutex> lock(*cLock);
-            OCHeaderOption options[MAX_HEADER_OPTIONS];
+            OCHeaderOption *options = assembleHeaderOptions(headerOptions);
 
             result = OCDoResource(nullptr, OC_REST_PUT,
                                   url.c_str(), &devAddr,
@@ -888,8 +902,9 @@ namespace OC
                                   CT_DEFAULT,
                                   static_cast<OCQualityOfService>(QoS),
                                   &cbdata,
-                                  assembleHeaderOptions(options, headerOptions),
+                                  options,
                                   headerOptions.size());
+             delete[] options;
         }
         else
         {
@@ -937,6 +952,13 @@ namespace OC
         {
             return OC_STACK_INVALID_PARAM;
         }
+
+        if (headerOptions.size() > MAX_HEADER_OPTIONS)
+        {
+            oclog() << "GetResourceRepresentation: Header options are more than MAX_HEADER_OPTIONS" << std::flush;
+            return OC_STACK_INVALID_PARAM;
+        }
+
         OCStackResult result;
         ClientCallbackContext::GetContext* ctx =
             new ClientCallbackContext::GetContext(callback);
@@ -953,7 +975,7 @@ namespace OC
         if (cLock)
         {
             std::lock_guard<std::recursive_mutex> lock(*cLock);
-            OCHeaderOption options[MAX_HEADER_OPTIONS];
+            OCHeaderOption *options = assembleHeaderOptions(headerOptions);
 
             result = OCDoResource(
                                   nullptr, OC_REST_GET,
@@ -962,8 +984,9 @@ namespace OC
                                   connectivityType,
                                   static_cast<OCQualityOfService>(QoS),
                                   &cbdata,
-                                  assembleHeaderOptions(options, headerOptions),
+                                  options,
                                   headerOptions.size());
+            delete[] options;
         }
         else
         {
@@ -1104,6 +1127,13 @@ namespace OC
         {
             return OC_STACK_INVALID_PARAM;
         }
+
+        if (headerOptions.size() > MAX_HEADER_OPTIONS)
+        {
+            oclog() << "PostResourceRepresentation: Header options are more than MAX_HEADER_OPTIONS" << std::flush;
+            return OC_STACK_INVALID_PARAM;
+        }
+
         OCStackResult result;
         ClientCallbackContext::SetContext* ctx = new ClientCallbackContext::SetContext(callback);
         OCCallbackData cbdata;
@@ -1119,7 +1149,7 @@ namespace OC
         if (cLock)
         {
             std::lock_guard<std::recursive_mutex> lock(*cLock);
-            OCHeaderOption options[MAX_HEADER_OPTIONS];
+            OCHeaderOption *options = assembleHeaderOptions(headerOptions);
 
             result = OCDoResource(nullptr, OC_REST_POST,
                                   url.c_str(), &devAddr,
@@ -1127,8 +1157,9 @@ namespace OC
                                   connectivityType,
                                   static_cast<OCQualityOfService>(QoS),
                                   &cbdata,
-                                  assembleHeaderOptions(options, headerOptions),
+                                  options,
                                   headerOptions.size());
+            delete[] options;
         }
         else
         {
@@ -1150,6 +1181,13 @@ namespace OC
         {
             return OC_STACK_INVALID_PARAM;
         }
+
+        if (headerOptions.size() > MAX_HEADER_OPTIONS)
+        {
+            oclog() << "PutResourceRepresentation: Header options are more than MAX_HEADER_OPTIONS" << std::flush;
+            return OC_STACK_INVALID_PARAM;
+        }
+
         OCStackResult result;
         ClientCallbackContext::SetContext* ctx = new ClientCallbackContext::SetContext(callback);
         OCCallbackData cbdata;
@@ -1166,7 +1204,7 @@ namespace OC
         {
             std::lock_guard<std::recursive_mutex> lock(*cLock);
             OCDoHandle handle;
-            OCHeaderOption options[MAX_HEADER_OPTIONS];
+            OCHeaderOption *options = assembleHeaderOptions(headerOptions);
 
             result = OCDoResource(&handle, OC_REST_PUT,
                                   url.c_str(), &devAddr,
@@ -1174,8 +1212,9 @@ namespace OC
                                   CT_DEFAULT,
                                   static_cast<OCQualityOfService>(QoS),
                                   &cbdata,
-                                  assembleHeaderOptions(options, headerOptions),
+                                  options,
                                   headerOptions.size());
+            delete[] options;
         }
         else
         {
@@ -1214,6 +1253,13 @@ namespace OC
         {
             return OC_STACK_INVALID_PARAM;
         }
+
+        if (headerOptions.size() > MAX_HEADER_OPTIONS)
+        {
+            oclog() << "DeleteResource: Header options are more than MAX_HEADER_OPTIONS" << std::flush;
+            return OC_STACK_INVALID_PARAM;
+        }
+
         OCStackResult result;
         ClientCallbackContext::DeleteContext* ctx =
             new ClientCallbackContext::DeleteContext(callback);
@@ -1227,7 +1273,7 @@ namespace OC
 
         if (cLock)
         {
-            OCHeaderOption options[MAX_HEADER_OPTIONS];
+            OCHeaderOption *options = assembleHeaderOptions(headerOptions);
 
             std::lock_guard<std::recursive_mutex> lock(*cLock);
 
@@ -1237,8 +1283,9 @@ namespace OC
                                   connectivityType,
                                   static_cast<OCQualityOfService>(m_cfg.QoS),
                                   &cbdata,
-                                  assembleHeaderOptions(options, headerOptions),
+                                  options,
                                   headerOptions.size());
+            delete[] options;
         }
         else
         {
@@ -1292,6 +1339,13 @@ namespace OC
         {
             return OC_STACK_INVALID_PARAM;
         }
+
+        if (headerOptions.size() > MAX_HEADER_OPTIONS)
+        {
+            oclog() << "ObserveResource: Header options are more than MAX_HEADER_OPTIONS" << std::flush;
+            return OC_STACK_INVALID_PARAM;
+        }
+
         OCStackResult result;
 
         ClientCallbackContext::ObserveContext* ctx =
@@ -1323,7 +1377,7 @@ namespace OC
         if (cLock)
         {
             std::lock_guard<std::recursive_mutex> lock(*cLock);
-            OCHeaderOption options[MAX_HEADER_OPTIONS];
+            OCHeaderOption *options = assembleHeaderOptions(headerOptions);
 
             result = OCDoResource(handle, method,
                                   url.c_str(), &devAddr,
@@ -1331,8 +1385,9 @@ namespace OC
                                   CT_DEFAULT,
                                   static_cast<OCQualityOfService>(QoS),
                                   &cbdata,
-                                  assembleHeaderOptions(options, headerOptions),
+                                  options,
                                   headerOptions.size());
+            delete[] options;
         }
         else
         {
@@ -1350,18 +1405,25 @@ namespace OC
             const HeaderOptions& headerOptions,
             QualityOfService QoS)
     {
+        if (headerOptions.size() > MAX_HEADER_OPTIONS)
+        {
+            oclog() << "CancelObserveResource: Header options are more than MAX_HEADER_OPTIONS" << std::flush;
+            return OC_STACK_INVALID_PARAM;
+        }
+
         OCStackResult result;
         auto cLock = m_csdkLock.lock();
 
         if (cLock)
         {
             std::lock_guard<std::recursive_mutex> lock(*cLock);
-            OCHeaderOption options[MAX_HEADER_OPTIONS];
+            OCHeaderOption *options = assembleHeaderOptions(headerOptions);
 
             result = OCCancel(handle,
                     static_cast<OCQualityOfService>(QoS),
-                    assembleHeaderOptions(options, headerOptions),
+                    options,
                     headerOptions.size());
+            delete[] options;
         }
         else
         {
@@ -1502,16 +1564,15 @@ namespace OC
         return OC_STACK_OK;
     }
 
-    OCHeaderOption* InProcClientWrapper::assembleHeaderOptions(OCHeaderOption options[],
-           const HeaderOptions& headerOptions)
+    OCHeaderOption* InProcClientWrapper::assembleHeaderOptions(const HeaderOptions& headerOptions)
     {
-        int i = 0;
-
         if ( headerOptions.size() == 0)
         {
             return nullptr;
         }
 
+        OCHeaderOption* options = new OCHeaderOption[headerOptions.size()];
+        int i = 0;
         for (auto it=headerOptions.begin(); it != headerOptions.end(); ++it)
         {
             options[i] = OCHeaderOption();
index 0fea345..bed8cf3 100644 (file)
@@ -41,7 +41,7 @@ namespace OCPlatformTest
                 << "' " << std::endl;
         return fopen(SVR_DB_FILE_NAME, mode);
     }
-    OCPersistentStorage gps {client_open, fread, fwrite, fclose, unlink };
+        OCPersistentStorage gps {client_open, fread, fwrite, fclose, unlink, NULL, NULL };
 
     // Callbacks
     OCEntityHandlerResult entityHandler(std::shared_ptr<OCResourceRequest> /*request*/)
index ccc096a..9382581 100755 (executable)
@@ -326,8 +326,11 @@ void *listeningFunc(void * data)
         result = OCProcess();
         if (result != OC_STACK_OK)
         {
-           printf("OCStack stop error");
+           printf("OCProcess error");
         }
+
+               // Sleep for 100 ms to avoid high CPU Utilization.              
+               usleep(100 * 1000); // 100 milli-seconds
     }
     return NULL;
 }
index 5f5187a..70afcdd 100644 (file)
@@ -258,7 +258,6 @@ cp ./resource/csdk/connectivity/api/*.h %{buildroot}%{_includedir}/
 cp ./resource/csdk/security/provisioning/include/oxm/*.h %{buildroot}%{_includedir}
 cp ./resource/csdk/security/provisioning/include/internal/*.h %{buildroot}%{_includedir}
 cp ./resource/csdk/security/provisioning/include/*.h %{buildroot}%{_includedir}
-cp ./resource/csdk/security/provisioning/sample/oic_svr_db_server_justworks.dat %{buildroot}%{_libdir}/oic_svr_db_server.dat
 cp out/%{TARGET_OS}/%{TARGET_ARCH}/%{build_mode}/resource/csdk/security/provisioning/sample/sampleserver_justworks %{ex_install_dir}/provision-sample/
 cp ./resource/csdk/security/provisioning/sample/oic_svr_db_server_justworks.dat %{ex_install_dir}/provision-sample/
 cp out/%{TARGET_OS}/%{TARGET_ARCH}/%{build_mode}/resource/csdk/security/provisioning/sample/sampleserver_randompin %{ex_install_dir}/provision-sample/
@@ -306,7 +305,6 @@ rm -rfv out %{buildroot}/out %{buildroot}/${HOME} ||:
 %{_libdir}/libmbedtls.so
 %{_libdir}/libocpmapi.so
 %{_libdir}/libocprovision.so
-%{_libdir}/oic_svr_db_server.dat
 %endif
 
 %files service
index d220a07..848ca7d 100644 (file)
@@ -258,7 +258,6 @@ cp ./resource/csdk/connectivity/api/*.h %{buildroot}%{_includedir}/
 cp ./resource/csdk/security/provisioning/include/oxm/*.h %{buildroot}%{_includedir}
 cp ./resource/csdk/security/provisioning/include/internal/*.h %{buildroot}%{_includedir}
 cp ./resource/csdk/security/provisioning/include/*.h %{buildroot}%{_includedir}
-cp ./resource/csdk/security/provisioning/sample/oic_svr_db_server_justworks.dat %{buildroot}%{_libdir}/oic_svr_db_server.dat
 cp out/%{TARGET_OS}/%{TARGET_ARCH}/%{build_mode}/resource/csdk/security/provisioning/sample/sampleserver_justworks %{ex_install_dir}/provision-sample/
 cp ./resource/csdk/security/provisioning/sample/oic_svr_db_server_justworks.dat %{ex_install_dir}/provision-sample/
 cp out/%{TARGET_OS}/%{TARGET_ARCH}/%{build_mode}/resource/csdk/security/provisioning/sample/sampleserver_randompin %{ex_install_dir}/provision-sample/
@@ -307,7 +306,6 @@ rm -rfv out %{buildroot}/out %{buildroot}/${HOME} ||:
 %{_libdir}/libmbedtls.so
 %{_libdir}/libocpmapi.so
 %{_libdir}/libocprovision.so
-%{_libdir}/oic_svr_db_server.dat
 %endif
 
 %files service
index d220a07..848ca7d 100644 (file)
@@ -258,7 +258,6 @@ cp ./resource/csdk/connectivity/api/*.h %{buildroot}%{_includedir}/
 cp ./resource/csdk/security/provisioning/include/oxm/*.h %{buildroot}%{_includedir}
 cp ./resource/csdk/security/provisioning/include/internal/*.h %{buildroot}%{_includedir}
 cp ./resource/csdk/security/provisioning/include/*.h %{buildroot}%{_includedir}
-cp ./resource/csdk/security/provisioning/sample/oic_svr_db_server_justworks.dat %{buildroot}%{_libdir}/oic_svr_db_server.dat
 cp out/%{TARGET_OS}/%{TARGET_ARCH}/%{build_mode}/resource/csdk/security/provisioning/sample/sampleserver_justworks %{ex_install_dir}/provision-sample/
 cp ./resource/csdk/security/provisioning/sample/oic_svr_db_server_justworks.dat %{ex_install_dir}/provision-sample/
 cp out/%{TARGET_OS}/%{TARGET_ARCH}/%{build_mode}/resource/csdk/security/provisioning/sample/sampleserver_randompin %{ex_install_dir}/provision-sample/
@@ -307,7 +306,6 @@ rm -rfv out %{buildroot}/out %{buildroot}/${HOME} ||:
 %{_libdir}/libmbedtls.so
 %{_libdir}/libocpmapi.so
 %{_libdir}/libocprovision.so
-%{_libdir}/oic_svr_db_server.dat
 %endif
 
 %files service