diff options
Diffstat (limited to 'source3/libsmb/clirap.c')
-rw-r--r-- | source3/libsmb/clirap.c | 59 |
1 files changed, 48 insertions, 11 deletions
diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 0955d1e3bb..8541af4c7d 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -35,17 +35,54 @@ bool cli_api(struct cli_state *cli, char **rparam, unsigned int *rprcnt, char **rdata, unsigned int *rdrcnt) { - cli_send_trans(cli,SMBtrans, - PIPE_LANMAN, /* Name */ - 0,0, /* fid, flags */ - NULL,0,0, /* Setup, length, max */ - param, prcnt, mprcnt, /* Params, length, max */ - data, drcnt, mdrcnt /* Data, length, max */ - ); - - return (cli_receive_trans(cli,SMBtrans, - rparam, rprcnt, - rdata, rdrcnt)); + NTSTATUS status; + + uint8_t *my_rparam, *my_rdata; + uint32_t num_my_rparam, num_my_rdata; + + status = cli_trans(talloc_tos(), cli, SMBtrans, + PIPE_LANMAN, 0, /* name, fid */ + 0, 0, /* function, flags */ + NULL, 0, 0, /* setup */ + (uint8_t *)param, prcnt, mprcnt, /* Params, length, max */ + (uint8_t *)data, drcnt, mdrcnt, /* Data, length, max */ + NULL, /* recv_flags2 */ + NULL, 0, NULL, /* rsetup */ + &my_rparam, 0, &num_my_rparam, + &my_rdata, 0, &num_my_rdata); + if (!NT_STATUS_IS_OK(status)) { + return false; + } + + /* + * I know this memcpy massively hurts, but there are just tons + * of callers of cli_api that eventually need changing to + * talloc + */ + + *rparam = (char *)memdup(my_rparam, num_my_rparam); + if (*rparam == NULL) { + goto fail; + } + *rprcnt = num_my_rparam; + TALLOC_FREE(my_rparam); + + *rdata = (char *)memdup(my_rdata, num_my_rdata); + if (*rdata == NULL) { + goto fail; + } + *rdrcnt = num_my_rdata; + TALLOC_FREE(my_rdata); + + return true; +fail: + TALLOC_FREE(my_rdata); + TALLOC_FREE(my_rparam); + *rparam = NULL; + *rprcnt = 0; + *rdata = NULL; + *rdrcnt = 0; + return false; } /**************************************************************************** |