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

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