Ian Kent ca38f0
autofs-5.0.6 - fix result null check in read_one_map()
Ian Kent ca38f0
Ian Kent ca38f0
From: Ian Kent <ikent@redhat.com>
Ian Kent ca38f0
Ian Kent ca38f0
Fix the check and reset to NULL of the LDAP library allocated result
Ian Kent ca38f0
within the loop to fetch paged query values.
Ian Kent ca38f0
---
Ian Kent ca38f0
Ian Kent ca38f0
 CHANGELOG             |    1 +
Ian Kent ca38f0
 modules/lookup_ldap.c |    7 ++++++-
Ian Kent ca38f0
 2 files changed, 7 insertions(+), 1 deletions(-)
Ian Kent ca38f0
Ian Kent ca38f0
Ian Kent ca38f0
diff --git a/CHANGELOG b/CHANGELOG
Ian Kent ca38f0
index 946a196..66b804f 100644
Ian Kent ca38f0
--- a/CHANGELOG
Ian Kent ca38f0
+++ b/CHANGELOG
Ian Kent ca38f0
@@ -4,6 +4,7 @@
Ian Kent ca38f0
 - improve mount location error reporting.
Ian Kent ca38f0
 - fix paged query more results check.
Ian Kent ca38f0
 - fix dumpmaps not reading maps.
Ian Kent ca38f0
+- fix result null check in read_one_map().
Ian Kent ca38f0
 
Ian Kent ca38f0
 28/06/2011 autofs-5.0.6
Ian Kent ca38f0
 -----------------------
Ian Kent ca38f0
diff --git a/modules/lookup_ldap.c b/modules/lookup_ldap.c
Ian Kent ca38f0
index a25050a..22ff355 100644
Ian Kent ca38f0
--- a/modules/lookup_ldap.c
Ian Kent ca38f0
+++ b/modules/lookup_ldap.c
Ian Kent ca38f0
@@ -2381,8 +2381,10 @@ static int read_one_map(struct autofs_point *ap,
Ian Kent ca38f0
 
Ian Kent ca38f0
 		if (rv == LDAP_ADMINLIMIT_EXCEEDED ||
Ian Kent ca38f0
 		    rv == LDAP_SIZELIMIT_EXCEEDED) {
Ian Kent ca38f0
-			if (sp.result)
Ian Kent ca38f0
+			if (sp.result) {
Ian Kent ca38f0
 				ldap_msgfree(sp.result);
Ian Kent ca38f0
+				sp.result = NULL;
Ian Kent ca38f0
+			}
Ian Kent ca38f0
 			if (sp.cookie) {
Ian Kent ca38f0
 				ber_bvfree(sp.cookie);
Ian Kent ca38f0
 				sp.cookie = NULL;
Ian Kent ca38f0
@@ -2402,6 +2404,8 @@ static int read_one_map(struct autofs_point *ap,
Ian Kent ca38f0
 		if (rv != LDAP_SUCCESS || !sp.result) {
Ian Kent ca38f0
 			unbind_ldap_connection(ap->logopt, sp.ldap, ctxt);
Ian Kent ca38f0
 			*result_ldap = rv;
Ian Kent ca38f0
+			if (sp.result)
Ian Kent ca38f0
+				ldap_msgfree(sp.result);
Ian Kent ca38f0
 			if (sp.cookie)
Ian Kent ca38f0
 				ber_bvfree(sp.cookie);
Ian Kent ca38f0
 			free(sp.query);
Ian Kent ca38f0
@@ -2419,6 +2423,7 @@ static int read_one_map(struct autofs_point *ap,
Ian Kent ca38f0
 			return NSS_STATUS_NOTFOUND;
Ian Kent ca38f0
 		}
Ian Kent ca38f0
 		ldap_msgfree(sp.result);
Ian Kent ca38f0
+		sp.result = NULL;
Ian Kent ca38f0
 	} while (sp.morePages == TRUE);
Ian Kent ca38f0
 
Ian Kent ca38f0
 	debug(ap->logopt, MODPREFIX "done updating map");