From 1d9616113207775916c816708fe442fe84ad0369 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 11 Nov 2010 14:54:25 +0100 Subject: s3: Convert cli_dfs_get_referral to cli_trans --- source3/libsmb/clidfs.c | 61 ++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 31 deletions(-) (limited to 'source3/libsmb') diff --git a/source3/libsmb/clidfs.c b/source3/libsmb/clidfs.c index 97c1e0407c..1c879884fe 100644 --- a/source3/libsmb/clidfs.c +++ b/source3/libsmb/clidfs.c @@ -618,7 +618,7 @@ static bool cli_dfs_check_error(struct cli_state *cli, NTSTATUS expected, Get the dfs referral link. ********************************************************************/ -bool cli_dfs_get_referral(TALLOC_CTX *ctx, +NTSTATUS cli_dfs_get_referral(TALLOC_CTX *ctx, struct cli_state *cli, const char *path, struct client_dfs_referral **refs, @@ -627,9 +627,9 @@ bool cli_dfs_get_referral(TALLOC_CTX *ctx, { unsigned int data_len = 0; unsigned int param_len = 0; - uint16 setup = TRANSACT2_GET_DFS_REFERRAL; - char *param = NULL; - char *rparam=NULL, *rdata=NULL; + uint16 setup[1]; + uint8_t *param = NULL; + uint8_t *rdata = NULL; char *p; char *endp; size_t pathlen = 2*(strlen(path)+1); @@ -638,43 +638,42 @@ bool cli_dfs_get_referral(TALLOC_CTX *ctx, uint16_t consumed_ucs; uint16 num_referrals; struct client_dfs_referral *referrals = NULL; - bool ret = false; + NTSTATUS status; *num_refs = 0; *refs = NULL; - param = SMB_MALLOC_ARRAY(char, 2+pathlen+2); + SSVAL(setup, 0, TRANSACT2_GET_DFS_REFERRAL); + + param = SMB_MALLOC_ARRAY(uint8_t, 2+pathlen+2); if (!param) { + status = NT_STATUS_NO_MEMORY; goto out; } SSVAL(param, 0, 0x03); /* max referral level */ - p = ¶m[2]; + p = (char *)(¶m[2]); path_ucs = (smb_ucs2_t *)p; p += clistr_push(cli, p, path, pathlen, STR_TERMINATE); param_len = PTR_DIFF(p, param); - if (!cli_send_trans(cli, SMBtrans2, - NULL, /* name */ - -1, 0, /* fid, flags */ - &setup, 1, 0, /* setup, length, max */ - param, param_len, 2, /* param, length, max */ - NULL, 0, cli->max_xmit /* data, length, max */ - )) { - goto out; - } - - if (!cli_receive_trans(cli, SMBtrans2, - &rparam, ¶m_len, - &rdata, &data_len)) { + status = cli_trans(talloc_tos(), cli, SMBtrans2, + NULL, 0xffff, 0, 0, + setup, 1, 0, + param, param_len, 2, + NULL, 0, cli->max_xmit, + NULL, + NULL, 0, NULL, /* rsetup */ + NULL, 0, NULL, + &rdata, 4, &data_len); + if (!NT_STATUS_IS_OK(status)) { goto out; } - if (data_len < 4) { goto out; } - endp = rdata + data_len; + endp = (char *)rdata + data_len; consumed_ucs = SVAL(rdata, 0); num_referrals = SVAL(rdata, 2); @@ -714,7 +713,7 @@ bool cli_dfs_get_referral(TALLOC_CTX *ctx, } /* start at the referrals array */ - p = rdata+8; + p = (char *)rdata+8; for (i=0; i endp) { goto out; @@ -750,8 +749,6 @@ bool cli_dfs_get_referral(TALLOC_CTX *ctx, } } - ret = true; - *num_refs = num_referrals; *refs = referrals; @@ -759,9 +756,8 @@ bool cli_dfs_get_referral(TALLOC_CTX *ctx, TALLOC_FREE(consumed_path); SAFE_FREE(param); - SAFE_FREE(rdata); - SAFE_FREE(rparam); - return ret; + TALLOC_FREE(rdata); + return status; } /******************************************************************** @@ -867,8 +863,9 @@ bool cli_resolve_path(TALLOC_CTX *ctx, return false; } - if (!cli_dfs_get_referral(ctx, cli_ipc, dfs_path, &refs, - &num_refs, &consumed) || !num_refs) { + status = cli_dfs_get_referral(ctx, cli_ipc, dfs_path, &refs, + &num_refs, &consumed); + if (!NT_STATUS_IS_OK(status) || !num_refs) { return false; } @@ -1054,7 +1051,9 @@ bool cli_check_msdfs_proxy(TALLOC_CTX *ctx, } } - res = cli_dfs_get_referral(ctx, cli, fullpath, &refs, &num_refs, &consumed); + status = cli_dfs_get_referral(ctx, cli, fullpath, &refs, + &num_refs, &consumed); + res = NT_STATUS_IS_OK(status); status = cli_tdis(cli); if (!NT_STATUS_IS_OK(status)) { -- cgit