svn commit: samba r18923 - in branches/SAMBA_3_0/source/libads: .

gd at samba.org gd at samba.org
Tue Sep 26 16:27:19 GMT 2006


Author: gd
Date: 2006-09-26 16:27:18 +0000 (Tue, 26 Sep 2006)
New Revision: 18923

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

Log:
Fix more memleaks.

Guenther

Modified:
   branches/SAMBA_3_0/source/libads/gpo.c
   branches/SAMBA_3_0/source/libads/gpo_util.c
   branches/SAMBA_3_0/source/libads/ldap.c


Changeset:
Modified: branches/SAMBA_3_0/source/libads/gpo.c
===================================================================
--- branches/SAMBA_3_0/source/libads/gpo.c	2006-09-26 16:26:43 UTC (rev 18922)
+++ branches/SAMBA_3_0/source/libads/gpo.c	2006-09-26 16:27:18 UTC (rev 18923)
@@ -276,6 +276,7 @@
 
 	if (ads_count_replies(ads, res) != 1) {
 		DEBUG(10,("ads_add_gpo_link: no result\n"));
+		ads_msgfree(ads, res);
 		return ADS_ERROR(LDAP_NO_SUCH_OBJECT);
 	}
 
@@ -286,6 +287,7 @@
 		gp_link_new = talloc_asprintf(mem_ctx, "%s[%s;%d]", gp_link, gpo_dn, gpo_opt);
 	}
 
+	ads_msgfree(ads, res);
 	if (gp_link_new == NULL) {
 		return ADS_ERROR(LDAP_NO_MEMORY);
 	}
@@ -334,6 +336,7 @@
 
 	if (ads_count_replies(ads, res) != 1) {
 		DEBUG(10,("ads_delete_gpo_link: no result\n"));
+		ads_msgfree(ads, res);
 		return ADS_ERROR(LDAP_NO_SUCH_OBJECT);
 	}
 
@@ -343,8 +346,9 @@
 	}
 
 	/* find link to delete */
-//	gp_link_new = talloc_asprintf(mem_ctx, "%s[%s;%d]", gp_link, gpo_dn, gpo_opt);
+	/* gp_link_new = talloc_asprintf(mem_ctx, "%s[%s;%d]", gp_link, gpo_dn, gpo_opt); */
 
+	ads_msgfree(ads, res);
 	if (gp_link_new == NULL) {
 		return ADS_ERROR(LDAP_NO_MEMORY);
 	}

Modified: branches/SAMBA_3_0/source/libads/gpo_util.c
===================================================================
--- branches/SAMBA_3_0/source/libads/gpo_util.c	2006-09-26 16:26:43 UTC (rev 18922)
+++ branches/SAMBA_3_0/source/libads/gpo_util.c	2006-09-26 16:27:18 UTC (rev 18923)
@@ -465,8 +465,6 @@
 	LDAPMessage *res = NULL;
 	uint32 uac;
 
-	return ADS_ERROR_NT(NT_STATUS_NOT_IMPLEMENTED);
-
 	filter = talloc_asprintf(mem_ctx, "(&(objectclass=user)(sAMAccountName=%s))", hostname);
 	if (filter == NULL) {
 		return ADS_ERROR(LDAP_NO_MEMORY);
@@ -481,19 +479,24 @@
 	}
 
 	if (ads_count_replies(ads, res) != 1) {
+		ads_msgfree(ads, res);
 		return ADS_ERROR(LDAP_NO_SUCH_OBJECT);
 	}
 
 	dn = ads_get_dn(ads, res);
 	if (dn == NULL) {
+		ads_msgfree(ads, res);
 		return ADS_ERROR(LDAP_NO_MEMORY);
 	}
 
 	if (!ads_pull_uint32(ads, res, "userAccountControl", &uac)) {
+		ads_msgfree(ads, res);
 		ads_memfree(ads, dn);
 		return ADS_ERROR(LDAP_NO_MEMORY);
 	}
 
+	ads_msgfree(ads, res);
+
 	if (!(uac & UF_WORKSTATION_TRUST_ACCOUNT)) {
 		ads_memfree(ads, dn);
 		return ADS_ERROR(LDAP_NO_SUCH_OBJECT);
@@ -505,15 +508,15 @@
 		return status;
 	}
 
+	ads_memfree(ads, dn);
+
 	status = gpo_process_gpo_list(ads, mem_ctx, &gpo_list, 
 				      cse_gpo_name_to_guid_string("Security"), 
 				      GPO_LIST_FLAG_MACHINE); 
 	if (!ADS_ERR_OK(status)) {
-		ads_memfree(ads, dn);
 		return status;
 	}
 
-	ads_memfree(ads, dn);
 	return ADS_ERROR(LDAP_SUCCESS);
 }
 

Modified: branches/SAMBA_3_0/source/libads/ldap.c
===================================================================
--- branches/SAMBA_3_0/source/libads/ldap.c	2006-09-26 16:26:43 UTC (rev 18922)
+++ branches/SAMBA_3_0/source/libads/ldap.c	2006-09-26 16:27:18 UTC (rev 18923)
@@ -2458,9 +2458,12 @@
 
 	service_name = ads_pull_string(ads, mem_ctx, res, "dsServiceName");
 	if (service_name == NULL) {
+		ads_msgfree(ads, res);
 		return ADS_ERROR(LDAP_NO_RESULTS_RETURNED);
 	}
 
+	ads_msgfree(ads, res);
+
 	/* go up three levels */
 	dn = ads_parent_dn(ads_parent_dn(ads_parent_dn(service_name)));
 	if (dn == NULL) {
@@ -2472,8 +2475,6 @@
 		return ADS_ERROR(LDAP_NO_MEMORY);
 	}
 
-	ads_msgfree(ads, res);
-
 	return status;
 	/*
 	dsServiceName: CN=NTDS Settings,CN=W2K3DC,CN=Servers,CN=Default-First-Site-Name,CN=Sites,CN=Configuration,DC=ber,DC=suse,DC=de
@@ -2508,37 +2509,45 @@
 
 	config_context = ads_pull_string(ads, mem_ctx, res, "configurationNamingContext");
 	if (config_context == NULL) {
+		ads_msgfree(ads, res);
 		return ADS_ERROR(LDAP_NO_MEMORY);
 	}
 
 	filter = talloc_asprintf(mem_ctx, "(cn=%s)", computer_name);
 	if (filter == NULL) {
+		ads_msgfree(ads, res);
 		return ADS_ERROR(LDAP_NO_MEMORY);
 	}
 
+	ads_msgfree(ads, res);
+
 	status = ads_do_search(ads, config_context, LDAP_SCOPE_SUBTREE, filter, NULL, &res);
 	if (!ADS_ERR_OK(status)) {
 		return status;
 	}
 
 	if (ads_count_replies(ads, res) != 1) {
+		ads_msgfree(ads, res);
 		return ADS_ERROR(LDAP_NO_SUCH_OBJECT);
 	}
 
 	dn = ads_get_dn(ads, res);
 	if (dn == NULL) {
+		ads_msgfree(ads, res);
 		return ADS_ERROR(LDAP_NO_MEMORY);
 	}
 
 	/* go up three levels */
 	parent = ads_parent_dn(ads_parent_dn(ads_parent_dn(dn)));
 	if (parent == NULL) {
+		ads_msgfree(ads, res);
 		ads_memfree(ads, dn);
 		return ADS_ERROR(LDAP_NO_MEMORY);
 	}
 
 	*site_dn = talloc_strdup(mem_ctx, parent);
 	if (*site_dn == NULL) {
+		ads_msgfree(ads, res);
 		ads_memfree(ads, dn);
 		ADS_ERROR(LDAP_NO_MEMORY);
 	}



More information about the samba-cvs mailing list