svn commit: samba r3765 - in trunk/source/libads: .

jra at samba.org jra at samba.org
Mon Nov 15 19:01:36 GMT 2004


Author: jra
Date: 2004-11-15 19:01:33 +0000 (Mon, 15 Nov 2004)
New Revision: 3765

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=3765

Log:
Ensure on failure that *res is always NULL.
Check for malloc fail. Fixes for bug #2036.
Jeremy.

Modified:
   trunk/source/libads/ldap.c


Changeset:
Modified: trunk/source/libads/ldap.c
===================================================================
--- trunk/source/libads/ldap.c	2004-11-15 18:57:22 UTC (rev 3764)
+++ trunk/source/libads/ldap.c	2004-11-15 19:01:33 UTC (rev 3765)
@@ -456,8 +456,6 @@
 	controls[1] = &PagedResults;
 	controls[2] = NULL;
 
-	*res = NULL;
-
 	/* we need to disable referrals as the openldap libs don't
 	   handle them and paged results at the same time.  Using them
 	   together results in the result record containing the server 
@@ -533,6 +531,7 @@
 	int count = 0;
 	ADS_STATUS status;
 
+	*res = NULL;
 	status = ads_do_paged_search(ads, bind_path, scope, expr, attrs, res,
 				     &count, &cookie);
 
@@ -623,6 +622,7 @@
 	char *utf8_expr, *utf8_path, **search_attrs = NULL;
 	TALLOC_CTX *ctx;
 
+	*res = NULL;
 	if (!(ctx = talloc_init("ads_do_search"))) {
 		DEBUG(1,("ads_do_search: talloc_init() failed!"));
 		return ADS_ERROR(LDAP_NO_MEMORY);
@@ -653,7 +653,6 @@
 
 	timeout.tv_sec = ADS_SEARCH_TIMEOUT;
 	timeout.tv_usec = 0;
-	*res = NULL;
 
 	/* see the note in ads_do_paged_search - we *must* disable referrals */
 	ldap_set_option(ads->ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF);
@@ -764,6 +763,8 @@
 	char *expr;
 	const char *attrs[] = {"*", "nTSecurityDescriptor", NULL};
 
+	*res = NULL;
+
 	/* the easiest way to find a machine account anywhere in the tree
 	   is to look for hostname$ */
 	if (asprintf(&expr, "(samAccountName=%s$)", machine) == -1) {
@@ -2494,6 +2495,10 @@
 
 	asprintf(&expr, "(&(objectclass=computer)(dnshostname=%s.%s))", 
 		 ads->config.ldap_server_name, ads->config.realm);
+	if (expr == NULL) {
+		ADS_ERROR_NT(NT_STATUS_NO_MEMORY);
+	}
+
 	rc = ads_search(ads, &res, expr, attrs);
 	free(expr);
 



More information about the samba-cvs mailing list