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

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