From 3822ce603149787ed5f22bccbe34a130dd31ee0b Mon Sep 17 00:00:00 2001 From: Amit Date: Thu, 1 Mar 2018 11:40:50 +0530 Subject: [PATCH] Update Snapshot(2018-02-28) Change-Id: Ie839b5c1dee0a1a559d04b20a40f549b48e8da6f Signed-off-by: Amit --- packaging/snapshot_history.txt | 6 ++++ .../src/adapter_util/ca_adapter_net_ssl.c | 6 ++++ .../connectivity/src/tcp_adapter/catcpadapter.c | 7 ++++- resource/csdk/security/src/doxmresource.c | 36 ++++++++++++++++++++++ .../resourceCache/include/ResourceCacheManager.h | 1 + .../src/resourceCache/src/ResourceCacheManager.cpp | 3 ++ 6 files changed, 58 insertions(+), 1 deletion(-) diff --git a/packaging/snapshot_history.txt b/packaging/snapshot_history.txt index b413230..a212b7f 100755 --- a/packaging/snapshot_history.txt +++ b/packaging/snapshot_history.txt @@ -1,3 +1,9 @@ +http://suprem.sec.samsung.net/jira/browse/CONPRO-1243 + +commit_info_2018-02-28.txt + +commit_id: e5ace7ad29ce01019f79c00bdb3bdbd16f5fbf49 +---------------------------------------------------------------------------------------------------------------------------------- http://suprem.sec.samsung.net/jira/browse/CONPRO-1237 commit_info_2018-02-21.txt diff --git a/resource/csdk/connectivity/src/adapter_util/ca_adapter_net_ssl.c b/resource/csdk/connectivity/src/adapter_util/ca_adapter_net_ssl.c index 7be3576..6dd925a 100644 --- a/resource/csdk/connectivity/src/adapter_util/ca_adapter_net_ssl.c +++ b/resource/csdk/connectivity/src/adapter_util/ca_adapter_net_ssl.c @@ -1698,6 +1698,11 @@ static void SetupCipher(mbedtls_ssl_config * config, CATransportAdapter_t adapte memset(g_cipherSuitesList, 0, sizeof(g_cipherSuitesList)); + if (SSL_CIPHER_MAX < g_caSslContext->cipher) + { + OIC_LOG(ERROR, NET_SSL_TAG, "Maximum ciphersuite index exceeded"); + } + // Add the preferred ciphersuite first if (SSL_CIPHER_MAX != g_caSslContext->cipher) { @@ -1708,6 +1713,7 @@ static void SetupCipher(mbedtls_ssl_config * config, CATransportAdapter_t adapte // Add PSK ciphersuite if (true == g_caSslContext->cipherFlag[0] && + SSL_CIPHER_MAX != g_caSslContext->cipher && MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 != tlsCipher[g_caSslContext->cipher][0]) { g_cipherSuitesList[index] = MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256; diff --git a/resource/csdk/connectivity/src/tcp_adapter/catcpadapter.c b/resource/csdk/connectivity/src/tcp_adapter/catcpadapter.c index 9eb0c76..ca176c6 100644 --- a/resource/csdk/connectivity/src/tcp_adapter/catcpadapter.c +++ b/resource/csdk/connectivity/src/tcp_adapter/catcpadapter.c @@ -592,8 +592,13 @@ int32_t CASendTCPMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLength, CADataType_t dataType) { + (void)endpoint; + (void)data; + (void)dataLength; (void)dataType; - return CAQueueTCPData(true, endpoint, data, dataLength); + + OIC_LOG(ERROR, TAG, "TCP adapter does not support multicast sending!"); + return 0; } CAResult_t CAReadTCPData() diff --git a/resource/csdk/security/src/doxmresource.c b/resource/csdk/security/src/doxmresource.c index 999c016..3128723 100644 --- a/resource/csdk/security/src/doxmresource.c +++ b/resource/csdk/security/src/doxmresource.c @@ -48,6 +48,7 @@ #include "srmutility.h" #include "pinoxmcommon.h" #include "oxmverifycommon.h" +#include "octhread.h" #if defined(__WITH_DTLS__) || defined (__WITH_TLS__) #include "pkix_interface.h" @@ -91,6 +92,8 @@ typedef enum ConfirmState{ }ConfirmState_t; static OicSecDoxm_t *gDoxm = NULL; +static oc_mutex g_mutexDoxm = NULL; +static bool g_isDoxmNull = false; static OCResourceHandle gDoxmHandle = NULL; static OicSecOxm_t gOicSecDoxmJustWorks = OIC_JUST_WORKS; @@ -160,6 +163,12 @@ void DeleteDoxmBinData(OicSecDoxm_t* doxm) //Clean doxm itself OICFree(doxm); } + + if(g_mutexDoxm) + { + oc_mutex_free(g_mutexDoxm); + g_mutexDoxm = NULL; + } } OCStackResult DoxmToCBORPayload(const OicSecDoxm_t *doxm, uint8_t **payload, size_t *size, @@ -1692,6 +1701,14 @@ OCEntityHandlerResult DoxmEntityHandler(OCEntityHandlerFlag flag, return ehRet; } + oc_mutex_lock(g_mutexDoxm); + + if(g_isDoxmNull) + { + oc_mutex_unlock(g_mutexDoxm); + return OC_EH_SERVICE_UNAVAILABLE; + } + if (flag & OC_REQUEST_FLAG) { OIC_LOG(DEBUG, TAG, "Flag includes OC_REQUEST_FLAG"); @@ -1717,6 +1734,8 @@ OCEntityHandlerResult DoxmEntityHandler(OCEntityHandlerFlag flag, OC_EH_OK : OC_EH_ERROR; break; } + + oc_mutex_unlock(g_mutexDoxm); } return ehRet; @@ -1913,6 +1932,15 @@ OCStackResult InitDoxmResource() { OCStackResult ret = OC_STACK_ERROR; + if (!g_mutexDoxm) + { + g_mutexDoxm = oc_mutex_new(); + if(!g_mutexDoxm) + { + return OC_STACK_ERROR; + } + } + gConfirmState = CONFIRM_STATE_READY; gConfirmMsgId = 0; @@ -1940,6 +1968,10 @@ OCStackResult InitDoxmResource() gDoxm = GetDoxmDefault(); } + oc_mutex_lock(g_mutexDoxm); + g_isDoxmNull = false; + oc_mutex_unlock(g_mutexDoxm); + //In case of the server is shut down unintentionally, we should initialize the owner if(gDoxm && (false == gDoxm->owned)) { @@ -1976,19 +2008,23 @@ OCStackResult InitDoxmResource() OCStackResult DeInitDoxmResource() { + oc_mutex_lock(g_mutexDoxm); OCStackResult ret = OCDeleteResource(gDoxmHandle); if (gDoxm != &gDefaultDoxm) { DeleteDoxmBinData(gDoxm); } gDoxm = NULL; + g_isDoxmNull = true; if (OC_STACK_OK == ret) { + oc_mutex_unlock(g_mutexDoxm); return OC_STACK_OK; } else { + oc_mutex_unlock(g_mutexDoxm); return OC_STACK_ERROR; } } diff --git a/service/resource-encapsulation/src/resourceCache/include/ResourceCacheManager.h b/service/resource-encapsulation/src/resourceCache/include/ResourceCacheManager.h index 01b9921..ae02cac 100644 --- a/service/resource-encapsulation/src/resourceCache/include/ResourceCacheManager.h +++ b/service/resource-encapsulation/src/resourceCache/include/ResourceCacheManager.h @@ -75,6 +75,7 @@ namespace OIC static std::unique_ptr> s_cacheDataList; std::map cacheIDmap; + std::list m_observeCacheList; std::map observeCacheIDmap; ResourceCacheManager() = default; diff --git a/service/resource-encapsulation/src/resourceCache/src/ResourceCacheManager.cpp b/service/resource-encapsulation/src/resourceCache/src/ResourceCacheManager.cpp index 8a3f020..386e809 100644 --- a/service/resource-encapsulation/src/resourceCache/src/ResourceCacheManager.cpp +++ b/service/resource-encapsulation/src/resourceCache/src/ResourceCacheManager.cpp @@ -88,6 +88,7 @@ namespace OIC auto newHandler = std::make_shared(pResource); newHandler->startCache(std::move(func)); + m_observeCacheList.push_back(newHandler); observeCacheIDmap.insert(std::make_pair(retID, newHandler)); return retID; @@ -133,6 +134,7 @@ namespace OIC if ((dataCacheIns == cacheIDmap.end() && observeIns == observeCacheIDmap.end()) || id == 0) { + lock.~lock_guard(); throw RCSInvalidParameterException {"[cancelResourceCache] CacheID is invaild"}; } @@ -146,6 +148,7 @@ namespace OIC { (observeIns->second).reset(); observeCacheIDmap.erase(id); + lock.~lock_guard(); throw; } (observeIns->second).reset(); -- 2.7.4