Blame SOURCES/autofs-5.0.9-fix-race-accessing-qdn-in-get_query_dn.patch

306fa1
autofs-5.0.9 - fix race accessing qdn in get_query_dn()
306fa1
306fa1
From: Ian Kent <raven@themaw.net>
306fa1
306fa1
Fix a couple of obvious problems in get_query_dn().
306fa1
306fa1
First, check dn is not NULL before attempting to duplicate it.
306fa1
And also protect the update of qdn in the context by a mutex.
306fa1
---
306fa1
 CHANGELOG             |    1 +
306fa1
 modules/lookup_ldap.c |    9 ++++++---
306fa1
 2 files changed, 7 insertions(+), 3 deletions(-)
306fa1
306fa1
--- autofs-5.0.7.orig/CHANGELOG
306fa1
+++ autofs-5.0.7/CHANGELOG
306fa1
@@ -129,6 +129,7 @@
306fa1
 - add serialization to sasl init.
306fa1
 - dont allocate dev_ctl_ops too early.
306fa1
 - fix incorrect round robin host detection.
306fa1
+- fix race accessing qdn in get_query_dn().
306fa1
 
306fa1
 25/07/2012 autofs-5.0.7
306fa1
 =======================
306fa1
--- autofs-5.0.7.orig/modules/lookup_ldap.c
306fa1
+++ autofs-5.0.7/modules/lookup_ldap.c
306fa1
@@ -461,16 +461,19 @@ static int get_query_dn(unsigned logopt,
306fa1
 	}
306fa1
 
306fa1
 	free(query);
306fa1
-	qdn = strdup(dn);
306fa1
-	ldap_memfree(dn);
306fa1
+	if (dn) {
306fa1
+		qdn = strdup(dn);
306fa1
+		ldap_memfree(dn);
306fa1
+	}
306fa1
 	ldap_msgfree(result);
306fa1
 	if (!qdn)
306fa1
 		return 0;
306fa1
 
306fa1
+	uris_mutex_lock(ctxt);
306fa1
 	if (ctxt->qdn)
306fa1
 		free(ctxt->qdn);
306fa1
-
306fa1
 	ctxt->qdn = qdn;
306fa1
+	uris_mutex_unlock(ctxt);
306fa1
 
306fa1
 	return 1;
306fa1
 }