[PATCH] s4: dfs referral, fix errors found by valgrind
Matthieu Patou
mat at matws.net
Thu May 13 15:34:32 MDT 2010
---
source4/smb_server/smb/trans2.c | 23 ++++++++++++-----------
1 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/source4/smb_server/smb/trans2.c b/source4/smb_server/smb/trans2.c
index fd13ea8..e24e42d 100644
--- a/source4/smb_server/smb/trans2.c
+++ b/source4/smb_server/smb/trans2.c
@@ -1214,9 +1214,9 @@ static NTSTATUS dodomain_referral(TALLOC_CTX *ctx, const struct dfs_GetDFSReferr
tab = talloc_array(context, struct dfs_referral_type, found_domain);
NT_STATUS_HAVE_NO_MEMORY_AND_FREE(tab, context);
- referral = talloc(context, struct dfs_referral_type);
+ referral = talloc(tab, struct dfs_referral_type);
status = fill_domain_dfs_referraltype(referral, 3,
- talloc_asprintf(context, "\\%s", strlower_talloc(context, realm)), NULL, 0);
+ talloc_asprintf(referral, "\\%s", strlower_talloc(referral, realm)), NULL, 0);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(2,(__location__ ":Unable to fill domain referral structure\n"));
talloc_free(context);
@@ -1224,9 +1224,9 @@ static NTSTATUS dodomain_referral(TALLOC_CTX *ctx, const struct dfs_GetDFSReferr
}
tab[current_pos] = *referral;
current_pos++;
- referral = talloc(context, struct dfs_referral_type);
+ referral = talloc(tab, struct dfs_referral_type);
status = fill_domain_dfs_referraltype(referral, 3,
- talloc_asprintf(context, "\\%s", domain), NULL, 0);
+ talloc_asprintf(referral, "\\%s", domain), NULL, 0);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(2,(__location__ ":Unable to fill domain referral structure\n"));
talloc_free(context);
@@ -1238,7 +1238,7 @@ static NTSTATUS dodomain_referral(TALLOC_CTX *ctx, const struct dfs_GetDFSReferr
resp.referral_entries = tab;
- ndr_err = ndr_push_struct_blob(outblob, context,
+ ndr_err = ndr_push_struct_blob(outblob, outblob,
lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &resp,
(ndr_push_flags_fn_t)ndr_push_dfs_referral_resp);
@@ -1254,12 +1254,13 @@ static NTSTATUS dodomain_referral(TALLOC_CTX *ctx, const struct dfs_GetDFSReferr
/* The answer is too big, so let's remove some answers*/
int ok = 0;
int remain = found_domain;
+ talloc_free(outblob);
while( ok ==0 && remain >2 ) {
/* Let's scrap the first referral*/
resp.nb_referrals = resp.nb_referrals - 1;
resp.referral_entries++;
remain--;
- ndr_err = ndr_push_struct_blob(outblob, context,
+ ndr_err = ndr_push_struct_blob(outblob, outblob,
lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &resp,
(ndr_push_flags_fn_t)ndr_push_dfs_referral_resp);
@@ -1427,7 +1428,7 @@ static NTSTATUS dodc_or_sysvol_referral(TALLOC_CTX *ctx, const struct dfs_GetDFS
/* Put here the code from filling the array for trusted domain */
referral = talloc(context, struct dfs_referral_type);
status = fill_domain_dfs_referraltype(referral, 3,
- talloc_asprintf(context, "\\%s",
+ talloc_asprintf(referral, "\\%s",
requestedname), (const char**) dc_list, num_dcs);
if (!NT_STATUS_IS_OK(status)) {
@@ -1437,7 +1438,7 @@ static NTSTATUS dodc_or_sysvol_referral(TALLOC_CTX *ctx, const struct dfs_GetDFS
}
resp.referral_entries = referral;
- ndr_err = ndr_push_struct_blob(outblob, context,
+ ndr_err = ndr_push_struct_blob(outblob, outblob,
lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &resp,
(ndr_push_flags_fn_t)ndr_push_dfs_referral_resp);
@@ -1466,10 +1467,10 @@ static NTSTATUS dodc_or_sysvol_referral(TALLOC_CTX *ctx, const struct dfs_GetDFS
for(i=0; set[i]; i++) {
for(j=0; j< set[i]->count; j++) {
- referral = talloc(context, struct dfs_referral_type);
+ referral = talloc(tab, struct dfs_referral_type);
status = fill_normal_dfs_referraltype(referral,
dfsreq.max_referral_level, requestedname,
- talloc_asprintf(context,"\\%s\\%s",set[i]->names[j],share), j==0);
+ talloc_asprintf(referral,"\\%s\\%s",set[i]->names[j],share), j==0);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(2, (__location__ ": Unable to fill a normal dfs referral object"));
talloc_free(context);
@@ -1481,7 +1482,7 @@ static NTSTATUS dodc_or_sysvol_referral(TALLOC_CTX *ctx, const struct dfs_GetDFS
}
resp.referral_entries = tab;
- ndr_err = ndr_push_struct_blob(outblob, context,
+ ndr_err = ndr_push_struct_blob(outblob, outblob,
lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")), &resp,
(ndr_push_flags_fn_t)ndr_push_dfs_referral_resp);
--
1.7.0.4
--------------000908030206000904010001--
More information about the samba-technical
mailing list