summaryrefslogtreecommitdiff
path: root/lib/util
diff options
context:
space:
mode:
authorRalph Boehme <slow@samba.org>2018-07-03 15:30:33 +0200
committerRalph Boehme <slow@samba.org>2018-07-04 21:07:09 +0200
commite311801e0e7171a2b50e39d3e0c2d2137f8b3d7e (patch)
treefc265a5b0cad2a02d57ee3a26734d85555b655a3 /lib/util
parenta958dc35bbeea61fa1344a10602e7d40c8339764 (diff)
downloadsamba-e311801e0e7171a2b50e39d3e0c2d2137f8b3d7e.tar.gz
lib: smb_threads: fix access before init bug
talloc_stackframe_internal() calls SMB_THREAD_GET_TLS(global_ts) which calls smb_get_tls_pthread() in the POSIX pthread wrapper implementation. If SMB_THREAD_SET_TLS() hasn't been called before, global_ts is NULL and smb_get_tls_pthread dereferences it so it crashes. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13505 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'lib/util')
-rw-r--r--lib/util/smb_threads.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/util/smb_threads.h b/lib/util/smb_threads.h
index 9a096167743..67d05b8c411 100644
--- a/lib/util/smb_threads.h
+++ b/lib/util/smb_threads.h
@@ -119,6 +119,9 @@ static int smb_set_tls_pthread(void *pkey, const void *pval, const char *locatio
\
static void *smb_get_tls_pthread(void *pkey, const char *location) \
{ \
+ if (pkey == NULL) { \
+ return NULL; \
+ } \
return pthread_getspecific(*(pthread_key_t *)pkey); \
} \
\