summaryrefslogtreecommitdiff
path: root/source3/nsswitch
diff options
context:
space:
mode:
authorGerald (Jerry) Carter <jerry@samba.org>2008-01-02 14:50:59 -0600
committerGerald (Jerry) Carter <jerry@samba.org>2008-01-02 14:50:59 -0600
commit701a56a698b580b21bfb0df73401ffe2d05f6f19 (patch)
tree891890cc1965e77e2d9f9fc456e282d614b713a5 /source3/nsswitch
parent4656265a2337db1ef99769a6b30c0cf04fdd6cff (diff)
downloadsamba-701a56a698b580b21bfb0df73401ffe2d05f6f19.tar.gz
samba-701a56a698b580b21bfb0df73401ffe2d05f6f19.tar.bz2
samba-701a56a698b580b21bfb0df73401ffe2d05f6f19.zip
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. (This used to be commit 39c2059f66ee9eb471a503b9c776807b91c2a8f8)
Diffstat (limited to 'source3/nsswitch')
-rw-r--r--source3/nsswitch/libwbclient/wbc_sid.c37
-rw-r--r--source3/nsswitch/libwbclient/wbc_util.c4
2 files changed, 19 insertions, 22 deletions
diff --git a/source3/nsswitch/libwbclient/wbc_sid.c b/source3/nsswitch/libwbclient/wbc_sid.c
index c877e1d9d4..8311a21a86 100644
--- a/source3/nsswitch/libwbclient/wbc_sid.c
+++ b/source3/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/source3/nsswitch/libwbclient/wbc_util.c b/source3/nsswitch/libwbclient/wbc_util.c
index c6acb27e55..7eb19731a7 100644
--- a/source3/nsswitch/libwbclient/wbc_util.c
+++ b/source3/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.
- *
**/