Fix a segment fault issue in TLS 90/14290/1
authorPing Yu <ping.yu@intel.com>
Thu, 16 Aug 2018 23:11:05 +0000 (19:11 -0400)
committerPing Yu <ping.yu@intel.com>
Thu, 16 Aug 2018 23:11:05 +0000 (19:11 -0400)
The root cause is it uses a dangling reference after memory move
Need to call session_alloc first, then use index to get the app
listener point

Change-Id: If5b7e0d6ddc761e5327660c47ce620e375319b4d
Signed-off-by: Ping Yu <ping.yu@intel.com>
src/vnet/tls/tls.c

index cea4491..88b4548 100644 (file)
@@ -156,14 +156,15 @@ tls_notify_app_accept (tls_ctx_t * ctx)
 
   app = application_get (ctx->parent_app_index);
   lctx = tls_listener_ctx_get (ctx->listener_ctx_index);
-  app_listener = listen_session_get_from_handle (lctx->app_session_handle);
-  sm = application_get_listen_segment_manager (app, app_listener);
 
   app_session = session_alloc (vlib_get_thread_index ());
   app_session->app_index = ctx->parent_app_index;
   app_session->connection_index = ctx->tls_ctx_handle;
+
+  app_listener = listen_session_get_from_handle (lctx->app_session_handle);
   app_session->session_type = app_listener->session_type;
   app_session->listener_index = app_listener->session_index;
+  sm = application_get_listen_segment_manager (app, app_listener);
   if ((rv = session_alloc_fifos (sm, app_session)))
     {
       TLS_DBG (1, "failed to allocate fifos");