diff options
author | Günther Deschner <gd@samba.org> | 2008-12-03 10:40:04 +0100 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2010-09-10 13:21:41 +0200 |
commit | c59961dd814965e1dedd172b5e11c31310b80cc7 (patch) | |
tree | 37b9f09721348e0fa236eefbf2d87092cf003dfc /source3/libsmb | |
parent | 33fdf8dac2dfd843ea10e3703d65b903b253270e (diff) | |
download | samba-c59961dd814965e1dedd172b5e11c31310b80cc7.tar.gz samba-c59961dd814965e1dedd172b5e11c31310b80cc7.tar.bz2 samba-c59961dd814965e1dedd172b5e11c31310b80cc7.zip |
s3-dsgetdcname: cleanup receive_getdc_response a little.
Guenther
Diffstat (limited to 'source3/libsmb')
-rw-r--r-- | source3/libsmb/clidgram.c | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/source3/libsmb/clidgram.c b/source3/libsmb/clidgram.c index f1f0bcb357..919ea93c91 100644 --- a/source3/libsmb/clidgram.c +++ b/source3/libsmb/clidgram.c @@ -201,13 +201,13 @@ bool receive_getdc_response(TALLOC_CTX *mem_ctx, const char *domain_name, uint32_t *nt_version, const char **dc_name, - struct netlogon_samlogon_response **_r) + struct netlogon_samlogon_response **samlogon_response) { struct packet_struct *packet; const char *my_mailslot = NULL; struct in_addr dc_ip; DATA_BLOB blob; - struct netlogon_samlogon_response r; + struct netlogon_samlogon_response *r; union dgram_message_body p; enum ndr_err_code ndr_err; NTSTATUS status; @@ -269,41 +269,45 @@ bool receive_getdc_response(TALLOC_CTX *mem_ctx, blob = p.smb.body.trans.data; - ZERO_STRUCT(r); + r = TALLOC_ZERO_P(mem_ctx, struct netlogon_samlogon_response); + if (!r) { + return false; + } - status = pull_netlogon_samlogon_response(&blob, mem_ctx, &r); + status = pull_netlogon_samlogon_response(&blob, mem_ctx, r); if (!NT_STATUS_IS_OK(status)) { + TALLOC_FREE(r); return false; } - map_netlogon_samlogon_response(&r); + map_netlogon_samlogon_response(r); /* do we still need this ? */ - *nt_version = r.ntver; + *nt_version = r->ntver; - returned_domain = r.data.nt5_ex.domain_name; - returned_dc = r.data.nt5_ex.pdc_name; + returned_domain = r->data.nt5_ex.domain_name; + returned_dc = r->data.nt5_ex.pdc_name; if (!strequal(returned_domain, domain_name)) { DEBUG(3, ("GetDC: Expected domain %s, got %s\n", domain_name, returned_domain)); + TALLOC_FREE(r); return false; } *dc_name = talloc_strdup(mem_ctx, returned_dc); if (!*dc_name) { + TALLOC_FREE(r); return false; } if (**dc_name == '\\') *dc_name += 1; if (**dc_name == '\\') *dc_name += 1; - if (_r) { - *_r = (struct netlogon_samlogon_response *)talloc_memdup( - mem_ctx, &r, sizeof(struct netlogon_samlogon_response)); - if (!*_r) { - return false; - } + if (samlogon_response) { + *samlogon_response = r; + } else { + TALLOC_FREE(r); } DEBUG(10, ("GetDC gave name %s for domain %s\n", |