summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-03-13 03:50:26 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:15:23 -0500
commit75247c5ea22f1a3572acd06b473baf0e560c54a5 (patch)
treeaf26df55b56182cb56af5fc45517a1316d1713a2
parent2167ec9dd5bc3e0a74460bda53d9d64d19c9c899 (diff)
downloadsamba-75247c5ea22f1a3572acd06b473baf0e560c54a5.tar.gz
samba-75247c5ea22f1a3572acd06b473baf0e560c54a5.tar.bz2
samba-75247c5ea22f1a3572acd06b473baf0e560c54a5.zip
r14282: Change centry_string to only use talloc. Should
quieten coverity bug #194 (which I think is a false positive). Jeremy. (This used to be commit 07d8b02d3dddf7322e096f3f0a7cc1c8fa709fa3)
-rw-r--r--source3/nsswitch/winbindd_cache.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/source3/nsswitch/winbindd_cache.c b/source3/nsswitch/winbindd_cache.c
index c99888be3e..cec76996c3 100644
--- a/source3/nsswitch/winbindd_cache.c
+++ b/source3/nsswitch/winbindd_cache.c
@@ -257,10 +257,7 @@ static char *centry_string(struct cache_entry *centry, TALLOC_CTX *mem_ctx)
smb_panic("centry_string");
}
- if (mem_ctx != NULL)
- ret = TALLOC(mem_ctx, len+1);
- else
- ret = SMB_MALLOC(len+1);
+ ret = TALLOC(mem_ctx, len+1);
if (!ret) {
smb_panic("centry_string out of memory\n");
}
@@ -273,14 +270,13 @@ static char *centry_string(struct cache_entry *centry, TALLOC_CTX *mem_ctx)
/* pull a string from a cache entry, using the supplied
talloc context
*/
-static BOOL centry_sid(struct cache_entry *centry, DOM_SID *sid)
+static BOOL centry_sid(struct cache_entry *centry, TALLOC_CTX *mem_ctx, DOM_SID *sid)
{
char *sid_string;
- sid_string = centry_string(centry, NULL);
+ sid_string = centry_string(centry, mem_ctx);
if (!string_to_sid(sid, sid_string)) {
return False;
}
- SAFE_FREE(sid_string);
return True;
}
@@ -912,8 +908,8 @@ static NTSTATUS query_user_list(struct winbindd_domain *domain,
(*info)[i].full_name = centry_string(centry, mem_ctx);
(*info)[i].homedir = centry_string(centry, mem_ctx);
(*info)[i].shell = centry_string(centry, mem_ctx);
- centry_sid(centry, &(*info)[i].user_sid);
- centry_sid(centry, &(*info)[i].group_sid);
+ centry_sid(centry, mem_ctx, &(*info)[i].user_sid);
+ centry_sid(centry, mem_ctx, &(*info)[i].group_sid);
}
do_cached:
@@ -1176,7 +1172,7 @@ static NTSTATUS name_to_sid(struct winbindd_domain *domain,
*type = (enum SID_NAME_USE)centry_uint32(centry);
status = centry->status;
if (NT_STATUS_IS_OK(status)) {
- centry_sid(centry, sid);
+ centry_sid(centry, mem_ctx, sid);
}
DEBUG(10,("name_to_sid: [Cached] - cached name for domain %s status %s\n",
@@ -1315,8 +1311,8 @@ static NTSTATUS query_user(struct winbindd_domain *domain,
info->full_name = centry_string(centry, mem_ctx);
info->homedir = centry_string(centry, mem_ctx);
info->shell = centry_string(centry, mem_ctx);
- centry_sid(centry, &info->user_sid);
- centry_sid(centry, &info->group_sid);
+ centry_sid(centry, mem_ctx, &info->user_sid);
+ centry_sid(centry, mem_ctx, &info->group_sid);
status = centry->status;
DEBUG(10,("query_user: [Cached] - cached info for domain %s status %s\n",
@@ -1387,7 +1383,7 @@ static NTSTATUS lookup_usergroups(struct winbindd_domain *domain,
if (! (*user_gids))
smb_panic("lookup_usergroups out of memory");
for (i=0; i<(*num_groups); i++) {
- centry_sid(centry, &(*user_gids)[i]);
+ centry_sid(centry, mem_ctx, &(*user_gids)[i]);
}
do_cached:
@@ -1549,7 +1545,7 @@ static NTSTATUS lookup_groupmem(struct winbindd_domain *domain,
}
for (i=0; i<(*num_names); i++) {
- centry_sid(centry, &(*sid_mem)[i]);
+ centry_sid(centry, mem_ctx, &(*sid_mem)[i]);
(*names)[i] = centry_string(centry, mem_ctx);
(*name_types)[i] = centry_uint32(centry);
}
@@ -1645,7 +1641,7 @@ static NTSTATUS trusted_domains(struct winbindd_domain *domain,
for (i=0; i<(*num_domains); i++) {
(*names)[i] = centry_string(centry, mem_ctx);
(*alt_names)[i] = centry_string(centry, mem_ctx);
- centry_sid(centry, &(*dom_sids)[i]);
+ centry_sid(centry, mem_ctx, &(*dom_sids)[i]);
}
status = centry->status;
@@ -2045,7 +2041,7 @@ BOOL lookup_cached_name(TALLOC_CTX *mem_ctx,
if (NT_STATUS_IS_OK(centry->status)) {
*type = (enum SID_NAME_USE)centry_uint32(centry);
- centry_sid(centry, sid);
+ centry_sid(centry, mem_ctx, sid);
}
status = centry->status;