Blob Blame History Raw
autofs-5.1.8 - avoid calling pthread_getspecific() with NULL key_thread_attempt_id

From: Ian Kent <raven@themaw.net>

Don't call pthread_getspecific() if key_thread_attempt_id is NULL in
case the pthread_getspecific() implementation doesn't check for this.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG |    1 +
 lib/log.c |    3 +++
 2 files changed, 4 insertions(+)

--- autofs-5.1.7.orig/CHANGELOG
+++ autofs-5.1.7/CHANGELOG
@@ -92,6 +92,7 @@
 - simplify cache_add() a little.
 - fix use after free in tree_mapent_delete_offset_tree().
 - fix memory leak in xdr_exports().
+- avoid calling pthread_getspecific() with NULL key_thread_attempt_id.
 
 25/01/2021 autofs-5.1.7
 - make bind mounts propagation slave by default.
--- autofs-5.1.7.orig/lib/log.c
+++ autofs-5.1.7/lib/log.c
@@ -38,6 +38,9 @@ static char *prepare_attempt_prefix(cons
 	char buffer[ATTEMPT_ID_SIZE + 1];
 	char *prefixed_msg = NULL;
 
+	if (!key_thread_attempt_id)
+		return NULL;
+
 	attempt_id = pthread_getspecific(key_thread_attempt_id);
 	if (attempt_id) {
 		int len = sizeof(buffer) + 1 + strlen(msg) + 1;