Fix crash in ssl retransmission thread 86/160986/1 accepted/tizen_3.0_common accepted/tizen_3.0_mobile accepted/tizen_3.0_tv accepted/tizen_3.0_wearable accepted/tizen/3.0/common/20171127.084406 accepted/tizen/3.0/mobile/20171127.041542 accepted/tizen/3.0/tv/20171127.041545 accepted/tizen/3.0/wearable/20171127.041550 submit/tizen_3.0/20171122.072736
authorJoonghwan Lee <jh05.lee@samsung.com>
Thu, 19 Jan 2017 08:33:20 +0000 (17:33 +0900)
committerHongkuk, Son <hongkuk.son@samsung.com>
Tue, 21 Nov 2017 03:25:02 +0000 (12:25 +0900)
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 <jh05.lee@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/16575
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Randeep Singh <randeep.s@samsung.com>
resource/csdk/connectivity/src/adapter_util/ca_adapter_net_ssl.c

index b490c8a..d0f44bd 100644 (file)
@@ -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