[SCM] Samba Shared Repository - branch v3-3-test updated - release-3-2-0pre2-4732-g0f02a16

Jeremy Allison jra at samba.org
Tue Dec 23 19:28:40 GMT 2008


The branch, v3-3-test has been updated
       via  0f02a165e23d716dcf3791eeaa6a5afebe7a1f88 (commit)
      from  9ebaf67d1dce717cafd5761b2f66296712a09957 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-3-test


- Log -----------------------------------------------------------------
commit 0f02a165e23d716dcf3791eeaa6a5afebe7a1f88
Author: Jeremy Allison <jeremy at jeremy-desktop.(none)>
Date:   Tue Dec 23 11:29:02 2008 -0800

    Fix more asprintf errors and error code paths.
    Jeremy.

-----------------------------------------------------------------------

Summary of changes:
 source/libads/ldap.c         |   14 +++++++++-----
 source/libads/ldap_printer.c |   26 ++++++++++++++++++++++----
 2 files changed, 31 insertions(+), 9 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/libads/ldap.c b/source/libads/ldap.c
index 215a310..291932d 100644
--- a/source/libads/ldap.c
+++ b/source/libads/ldap.c
@@ -603,7 +603,10 @@ got_connection:
 		/* Must use the userPrincipalName value here or sAMAccountName
 		   and not servicePrincipalName; found by Guenther Deschner */
 
-		asprintf(&ads->auth.user_name, "%s$", global_myname() );
+		if (asprintf(&ads->auth.user_name, "%s$", global_myname() ) == -1) {
+			DEBUG(0,("ads_connect: asprintf fail.\n"));
+			ads->auth.user_name = NULL;
+		}
 	}
 
 	if (!ads->auth.realm) {
@@ -619,10 +622,11 @@ got_connection:
 	/* this is a really nasty hack to avoid ADS DNS problems. It needs a patch
 	   to MIT kerberos to work (tridge) */
 	{
-		char *env;
-		asprintf(&env, "KRB5_KDC_ADDRESS_%s", ads->config.realm);
-		setenv(env, ads->auth.kdc_server, 1);
-		free(env);
+		char *env = NULL;
+		if (asprintf(&env, "KRB5_KDC_ADDRESS_%s", ads->config.realm) > 0) {
+			setenv(env, ads->auth.kdc_server, 1);
+			free(env);
+		}
 	}
 #endif
 
diff --git a/source/libads/ldap_printer.c b/source/libads/ldap_printer.c
index 9935e23..eb6e3d3 100644
--- a/source/libads/ldap_printer.c
+++ b/source/libads/ldap_printer.c
@@ -31,7 +31,7 @@
 				       const char *servername)
 {
 	ADS_STATUS status;
-	char *srv_dn, **srv_cn, *s;
+	char *srv_dn, **srv_cn, *s = NULL;
 	const char *attrs[] = {"*", "nTSecurityDescriptor", NULL};
 
 	status = ads_find_machine_acct(ads, res, servername);
@@ -41,25 +41,43 @@
 		return status;
 	}
 	if (ads_count_replies(ads, *res) != 1) {
+		if (res) {
+			ads_msgfree(ads, *res);
+			*res = NULL;
+		}
 		return ADS_ERROR(LDAP_NO_SUCH_OBJECT);
 	}
 	srv_dn = ldap_get_dn(ads->ldap.ld, *res);
 	if (srv_dn == NULL) {
+		if (res) {
+			ads_msgfree(ads, *res);
+			*res = NULL;
+		}
 		return ADS_ERROR(LDAP_NO_MEMORY);
 	}
 	srv_cn = ldap_explode_dn(srv_dn, 1);
 	if (srv_cn == NULL) {
 		ldap_memfree(srv_dn);
+		if (res) {
+			ads_msgfree(ads, *res);
+			*res = NULL;
+		}
 		return ADS_ERROR(LDAP_INVALID_DN_SYNTAX);
 	}
-	ads_msgfree(ads, *res);
+	if (res) {
+		ads_msgfree(ads, *res);
+		*res = NULL;
+	}
 
-	asprintf(&s, "(cn=%s-%s)", srv_cn[0], printer);
+	if (asprintf(&s, "(cn=%s-%s)", srv_cn[0], printer) == -1) {
+		ldap_memfree(srv_dn);
+		return ADS_ERROR(LDAP_NO_MEMORY);
+	}
 	status = ads_search(ads, res, s, attrs);
 
 	ldap_memfree(srv_dn);
 	ldap_value_free(srv_cn);
-	free(s);
+	SAFE_FREE(s);
 	return status;	
 }
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list