[SCM] Samba Shared Repository - branch v3-2-test updated - initial-v3-2-unstable-996-g7618583

Gerald (Jerry) Carter jerry at samba.org
Wed Jan 2 23:17:29 GMT 2008


The branch, v3-2-test has been updated
       via  761858312b3470ff2acc2980882bad534275c552 (commit)
       via  f22c9d6296c754d472e8eab51caa058f55ef370e (commit)
       via  39c2059f66ee9eb471a503b9c776807b91c2a8f8 (commit)
      from  1b06ee69f6b737c1d6e7b29f8ae9621e6eb07d27 (commit)

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


- Log -----------------------------------------------------------------
commit 761858312b3470ff2acc2980882bad534275c552
Merge: 1b06ee69f6b737c1d6e7b29f8ae9621e6eb07d27 f22c9d6296c754d472e8eab51caa058f55ef370e
Author: Gerald (Jerry) Carter <jerry at samba.org>
Date:   Wed Jan 2 17:15:10 2008 -0600

    Merge branch 'work/v3-2-test' into v3-2-test

commit f22c9d6296c754d472e8eab51caa058f55ef370e
Author: Gerald (Jerry) Carter <jerry at samba.org>
Date:   Wed Jan 2 14:54:25 2008 -0600

    use C99 bool return types (true & false).

commit 39c2059f66ee9eb471a503b9c776807b91c2a8f8
Author: Gerald (Jerry) Carter <jerry at samba.org>
Date:   Wed Jan 2 14:50:59 2008 -0600

    Make sure that wbcLookupSid() and wbcLookupRids() use talloc()'d memory.
    
    Follows existing convention that all returned memory should be freed with
    wbcFreeMemory() and not directly with free().  Noticed by Volker.  Txs.

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

Summary of changes:
 source/lib/winbind_util.c              |   49 ++++++++++++++++---------------
 source/nsswitch/libwbclient/wbc_sid.c  |   37 ++++++++++++-----------
 source/nsswitch/libwbclient/wbc_util.c |    4 --
 3 files changed, 44 insertions(+), 46 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/lib/winbind_util.c b/source/lib/winbind_util.c
index f51a017..3cf068a 100644
--- a/source/lib/winbind_util.c
+++ b/source/lib/winbind_util.c
@@ -35,12 +35,12 @@ bool winbind_lookup_name(const char *dom_name, const char *name, DOM_SID *sid,
 
 	result = wbcLookupName(dom_name, name, &dom_sid, &type);
 	if (result != WBC_ERR_SUCCESS)
-		return False;
+		return false;
 
 	memcpy(sid, &dom_sid, sizeof(DOM_SID));	
 	*name_type = (enum lsa_SidType)type;	
 
-	return True;	
+	return true;	
 }
 
 /* Call winbindd to convert sid to name */
@@ -59,7 +59,7 @@ bool winbind_lookup_sid(TALLOC_CTX *mem_ctx, const DOM_SID *sid,
 
 	result = wbcLookupSid(&dom_sid, &domain_name, &account_name, &type);
 	if (result != WBC_ERR_SUCCESS)
-		return False;
+		return false;
 
 	/* Copy out result */
 
@@ -74,16 +74,16 @@ bool winbind_lookup_sid(TALLOC_CTX *mem_ctx, const DOM_SID *sid,
 	DEBUG(10, ("winbind_lookup_sid: SUCCESS: SID %s -> %s %s\n", 
 		   sid_string_dbg(sid), domain_name, account_name));
 
-	SAFE_FREE(domain_name);
-	SAFE_FREE(account_name);
+	wbcFreeMemory(domain_name);
+	wbcFreeMemory(account_name);
 	
 	if ((domain && !*domain) || (name && !*name)) {		
 		DEBUG(0,("winbind_lookup_sid: talloc() failed!\n"));
-		return False;
+		return false;
 	}	
 
 
-	return True;
+	return true;
 }
 
 /* Ping winbindd to see it is alive */
@@ -192,8 +192,9 @@ bool winbind_lookup_rids(TALLOC_CTX *mem_ctx,
 	
 	ret = wbcLookupRids(&dom_sid, num_rids, rids,
 			    &dom_name, &namelist, &name_types);
-	if (ret != WBC_ERR_SUCCESS)
-		return False;
+	if (ret != WBC_ERR_SUCCESS) {		
+		return false;
+	}	
 	
 	*domain_name = talloc_strdup(mem_ctx, dom_name);
 	*names       = TALLOC_ARRAY(mem_ctx, const char*, num_rids);
@@ -202,13 +203,13 @@ bool winbind_lookup_rids(TALLOC_CTX *mem_ctx,
 	for(i=0; i<num_rids; i++) {
 		(*names)[i] = talloc_strdup(names, namelist[i]);
 		(*types)[i] = (enum lsa_SidType)name_types[i];
-
-		free(CONST_DISCARD(char*, namelist[i]));		
 	}
-	free(namelist);
-	free(name_types);
+
+	wbcFreeMemory(CONST_DISCARD(char*, dom_name));
+	wbcFreeMemory(namelist);
+	wbcFreeMemory(name_types);
 	
-	return True;	
+	return true;	
 }
 
 /* Ask Winbind to allocate a new uid for us */
@@ -238,7 +239,7 @@ bool winbind_allocate_gid(gid_t *gid)
 bool winbind_lookup_name(const char *dom_name, const char *name, DOM_SID *sid, 
                          enum lsa_SidType *name_type)
 {
-	return False;
+	return false;
 }
 
 /* Call winbindd to convert sid to name */
@@ -247,42 +248,42 @@ bool winbind_lookup_sid(TALLOC_CTX *mem_ctx, const DOM_SID *sid,
 			const char **domain, const char **name,
                         enum lsa_SidType *name_type)
 {
-	return False;
+	return false;
 }
 
 /* Ping winbindd to see it is alive */
 
 bool winbind_ping(void)
 {
-	return False;
+	return false;
 }
 
 /* Call winbindd to convert SID to uid */
 
 bool winbind_sid_to_uid(uid_t *puid, const DOM_SID *sid)
 {
-	return False;
+	return false;
 }
 
 /* Call winbindd to convert uid to sid */
 
 bool winbind_uid_to_sid(DOM_SID *sid, uid_t uid)
 {
-	return False;
+	return false;
 }
 
 /* Call winbindd to convert SID to gid */
 
 bool winbind_sid_to_gid(gid_t *pgid, const DOM_SID *sid)
 {
-	return False;	
+	return false;	
 }
 
 /* Call winbindd to convert gid to sid */
 
 bool winbind_gid_to_sid(DOM_SID *sid, gid_t gid)
 {
-	return False;
+	return false;
 }
 
 /* Check for a trusted domain */
@@ -300,21 +301,21 @@ bool winbind_lookup_rids(TALLOC_CTX *mem_ctx,
 			 const char **domain_name,
 			 const char ***names, enum lsa_SidType **types)
 {
-	return False;
+	return false;
 }
 
 /* Ask Winbind to allocate a new uid for us */
 
 bool winbind_allocate_uid(uid_t *uid)
 {
-	return False;
+	return false;
 }
 
 /* Ask Winbind to allocate a new gid for us */
 
 bool winbind_allocate_gid(gid_t *gid)
 {
-	return False;
+	return false;
 }
 
 #endif     /* WITH_WINBIND */
diff --git a/source/nsswitch/libwbclient/wbc_sid.c b/source/nsswitch/libwbclient/wbc_sid.c
index c877e1d..8311a21 100644
--- a/source/nsswitch/libwbclient/wbc_sid.c
+++ b/source/nsswitch/libwbclient/wbc_sid.c
@@ -265,12 +265,12 @@ wbcErr wbcLookupSid(const struct wbcDomainSid *sid,
 	/* Copy out result */
 
 	if (domain != NULL) {
-		*domain = strdup(response.data.name.dom_name);
+		*domain = talloc_strdup(NULL, response.data.name.dom_name);
 		BAIL_ON_PTR_ERROR((*domain), wbc_status);
 	}
 
 	if (name != NULL) {
-		*name = strdup(response.data.name.name);
+		*name = talloc_strdup(NULL, response.data.name.name);
 		BAIL_ON_PTR_ERROR((*name), wbc_status);
 	}
 
@@ -283,9 +283,9 @@ wbcErr wbcLookupSid(const struct wbcDomainSid *sid,
  done:
 	if (!WBC_ERROR_IS_OK(wbc_status)) {
 		if (*domain)
-			free(*domain);
+			talloc_free(*domain);
 		if (*name)
-			free(*name);
+			talloc_free(*name);
 	}
 
 	return wbc_status;
@@ -334,11 +334,9 @@ wbcErr wbcLookupRids(struct wbcDomainSid *dom_sid,
 
 	ridbuf_size = (sizeof(char)*11) * num_rids + 1;
 
-	ridlist = malloc(ridbuf_size);
+	ridlist = talloc_zero_array(NULL, char, ridbuf_size);
 	BAIL_ON_PTR_ERROR(ridlist, wbc_status);
 
-	memset(ridlist, 0x0, ridbuf_size);
-
 	len = 0;
 	for (i=0; i<num_rids && (len-1)>0; i++) {
 		char ridstr[12];
@@ -356,15 +354,15 @@ wbcErr wbcLookupRids(struct wbcDomainSid *dom_sid,
 	wbc_status = wbcRequestResponse(WINBINDD_LOOKUPRIDS,
 					&request,
 					&response);
-	free(ridlist);
+	talloc_free(ridlist);
 
-	domain_name = strdup(response.data.domain_name);
+	domain_name = talloc_strdup(NULL, response.data.domain_name);
 	BAIL_ON_PTR_ERROR(domain_name, wbc_status);
 
-	*names = (const char**)malloc(sizeof(char*) * num_rids);
+	*names = talloc_array(NULL, const char*, num_rids);
 	BAIL_ON_PTR_ERROR((*names), wbc_status);
 
-	*types = (enum wbcSidType*)malloc(sizeof(enum wbcSidType) * num_rids);
+	*types = talloc_array(NULL, enum wbcSidType, num_rids);
 	BAIL_ON_PTR_ERROR((*types), wbc_status);
 
 	p = (char *)response.extra_data.data;
@@ -393,7 +391,8 @@ wbcErr wbcLookupRids(struct wbcDomainSid *dom_sid,
 
 		*q = '\0';
 
-		(*names)[i] = strdup(p);
+		(*names)[i] = talloc_strdup((*names), p);
+		BAIL_ON_PTR_ERROR(((*names)[i]), wbc_status);		
 
 		p = q+1;
 	}
@@ -403,21 +402,23 @@ wbcErr wbcLookupRids(struct wbcDomainSid *dom_sid,
 		BAIL_ON_WBC_ERROR(wbc_status);
 	}
 
-	free(response.extra_data.data);
-
 	wbc_status = WBC_ERR_SUCCESS;
 
  done:
+	if (response.extra_data.data) {		
+		free(response.extra_data.data);
+	}	
+		
 	if (!WBC_ERROR_IS_OK(wbc_status)) {
 		if (domain_name)
-			free(domain_name);
+			talloc_free(domain_name);
 		if (*names)
-			free(*names);
+			talloc_free(*names);
 		if (*types)
-			free(*types);
+			talloc_free(*types);
 	} else {
 		*pp_domain_name = domain_name;
 	}
 
 	return wbc_status;
-}
+} 
diff --git a/source/nsswitch/libwbclient/wbc_util.c b/source/nsswitch/libwbclient/wbc_util.c
index c6acb27..7eb1973 100644
--- a/source/nsswitch/libwbclient/wbc_util.c
+++ b/source/nsswitch/libwbclient/wbc_util.c
@@ -51,10 +51,6 @@ wbcErr wbcPing(void)
  *
  * @return #wbcErr
  *
- * The char* members of the struct wbcDomainInfo* are malloc()'d
- * and it the the responsibility of the caller to free the members
- * before  discarding the struct.
- *
  **/
 
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list