From 98c364078f161695908499f5a1ee21049c01d22f Mon Sep 17 00:00:00 2001 From: Joonghwan Lee Date: Thu, 19 Jan 2017 17:33:20 +0900 Subject: [PATCH] Fix crash in ssl retransmission thread It is possible to happen segmentation fault if retransmission thread lock a mutex during CAdeinitSslAdapter function is called Patch 1: Initial upload Change-Id: I446aeb2cc9d6cd07d2683984ba2783ab72020c58 Signed-off-by: Joonghwan Lee Reviewed-on: https://gerrit.iotivity.org/gerrit/16575 Tested-by: jenkins-iotivity Reviewed-by: Randeep Singh --- resource/csdk/connectivity/src/adapter_util/ca_adapter_net_ssl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 b490c8a..d0f44bd 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 @@ -1214,6 +1214,7 @@ static void StopRetransmit() if (g_caSslContext) { unregisterTimer(g_caSslContext->timerId); + g_caSslContext->timerId= -1; } } #endif @@ -1292,12 +1293,14 @@ static int StartRetransmit() uint32_t listIndex = 0; uint32_t listLength = 0; SslEndPoint_t *tep = NULL; + + ca_mutex_lock(g_sslContextMutex); if (NULL == g_caSslContext) { OIC_LOG(ERROR, NET_SSL_TAG, "Context is NULL. Stop retransmission"); + ca_mutex_unlock(g_sslContextMutex); return -1; } - ca_mutex_lock(g_sslContextMutex); if (g_caSslContext->timerId != -1) { //clear previous timer -- 2.7.4