From d16b427bc946660da1b5a4421aacb585dd0a07ad Mon Sep 17 00:00:00 2001 From: midipix Date: Mon, 16 Jan 2017 04:37:53 +0000 Subject: __ntapi_dsr_start_impl(): copy the loop routine addr and ctx onto the stack. Since params might point to an address on the stack of the thread which called __ntapi_dsr_init(), and given that __ntapi_dsr_init() returns as soon as the internal client connection had been established, we may not access params upon return from __ntapi_dsr_connect_internal_client(). --- src/daemon/ntapi_dsr_init.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/daemon/ntapi_dsr_init.c b/src/daemon/ntapi_dsr_init.c index b54131e..f556f0b 100644 --- a/src/daemon/ntapi_dsr_init.c +++ b/src/daemon/ntapi_dsr_init.c @@ -145,8 +145,10 @@ static int32_t __ntapi_dsr_start_impl(nt_daemon_params * params) { int32_t status; void * ctx; + int32_t (*loop)(void *); - ctx = params->daemon_loop_context; + ctx = params->daemon_loop_context; + loop = params->daemon_loop_routine; if ((status = __ntapi_dsr_once(params))) return status; @@ -157,7 +159,7 @@ static int32_t __ntapi_dsr_start_impl(nt_daemon_params * params) if ((status = __ntapi_dsr_connect_internal_client(params))) return status; - if ((status = params->daemon_loop_routine(ctx))) + if ((status = loop(ctx))) return status; return NT_STATUS_SUCCESS; -- cgit v1.2.3