Skip to contentSkip to conversation

lookup_ldap.c: set result pointer to NULL when search fails

PATCH New Jeff Moyer 1 participant 1 message Sep 4, 2009 Kernel automounter

lore
Share & tools
lore

Jeff Moyer

author
#0 lore raw

PATCH 1/1 lookup_ldap.c: set result pointer to NULL when search fails

Hi, Ian,

It looks like we could end up with a result pointer that is non-null from a failed call to ldap_search_s. At least, in my brief look at the library code it looks like this *might* happen. So, to be safe, let's check for that.

Cheers,
Jeff

modules/lookup_ldap.c +4 -0
index 2ecf5fe..3a31a8e 100644
@@ -390,6 +390,10 @@ static int get_query_dn(unsigned logopt, LDAP *ldap, struct lookup_context *ctxt
 				error(logopt,
 				      MODPREFIX "query failed for search dn %s: %s",
 				      this->basedn, ldap_err2string(rv));
+				if (result) {
+					ldap_msgfree(result);
+					result = NULL;
+				}
 			}
 
 			this = this->next;