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

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