struct tevent_req *cli_read_andx_create(TALLOC_CTX *mem_ctx,
struct event_context *ev,
- struct cli_state *cli, int fnum,
+ struct cli_state *cli, uint16_t fnum,
off_t offset, size_t size,
struct tevent_req **psmbreq)
{
struct tevent_req *cli_read_andx_send(TALLOC_CTX *mem_ctx,
struct event_context *ev,
- struct cli_state *cli, int fnum,
+ struct cli_state *cli, uint16_t fnum,
off_t offset, size_t size)
{
struct tevent_req *req, *subreq;
+ NTSTATUS status;
req = cli_read_andx_create(mem_ctx, ev, cli, fnum, offset, size,
&subreq);
- if ((req == NULL) || !cli_smb_req_send(subreq)) {
- TALLOC_FREE(req);
+ if (req == NULL) {
return NULL;
}
+
+ status = cli_smb_req_send(subreq);
+ if (!NT_STATUS_IS_OK(status)) {
+ tevent_req_nterror(req, status);
+ return tevent_req_post(req, ev);
+ }
return req;
}
state->buf = (uint8_t *)smb_base(inbuf) + SVAL(vwv+6, 0);
if (trans_oob(smb_len(inbuf), SVAL(vwv+6, 0), state->received)
- || (state->buf < bytes)) {
+ || (state->received && (state->buf < bytes))) {
DEBUG(5, ("server returned invalid read&x data offset\n"));
tevent_req_nterror(req, NT_STATUS_INVALID_NETWORK_RESPONSE);
return;
return NT_STATUS_OK;
}
-ssize_t cli_read(struct cli_state *cli, int fnum, char *buf,
+ssize_t cli_read(struct cli_state *cli, uint16_t fnum, char *buf,
off_t offset, size_t size)
{
NTSTATUS status;
****************************************************************************/
static bool cli_issue_write(struct cli_state *cli,
- int fnum,
+ uint16_t fnum,
off_t offset,
uint16 mode,
const char *buf,
****************************************************************************/
ssize_t cli_write(struct cli_state *cli,
- int fnum, uint16 write_mode,
+ uint16_t fnum, uint16 write_mode,
const char *buf, off_t offset, size_t size)
{
ssize_t bwritten = 0;
****************************************************************************/
ssize_t cli_smbwrite(struct cli_state *cli,
- int fnum, char *buf, off_t offset, size_t size1)
+ uint16_t fnum, char *buf, off_t offset, size_t size1)
{
char *p;
ssize_t total = 0;
}
state->pad = 0;
- state->iov[0].iov_base = &state->pad;
+ state->iov[0].iov_base = (void *)&state->pad;
state->iov[0].iov_len = 1;
- state->iov[1].iov_base = CONST_DISCARD(uint8_t *, buf);
+ state->iov[1].iov_base = CONST_DISCARD(void *, buf);
state->iov[1].iov_len = size;
subreq = cli_smb_req_create(state, ev, cli, SMBwriteX, 0, wct, vwv,
off_t offset, size_t size)
{
struct tevent_req *req, *subreq;
+ NTSTATUS status;
req = cli_write_andx_create(mem_ctx, ev, cli, fnum, mode, buf, offset,
size, NULL, 0, &subreq);
- if ((req == NULL) || !cli_smb_req_send(subreq)) {
- TALLOC_FREE(req);
+ if (req == NULL) {
return NULL;
}
+
+ status = cli_smb_req_send(subreq);
+ if (!NT_STATUS_IS_OK(status)) {
+ tevent_req_nterror(req, status);
+ return tevent_req_post(req, ev);
+ }
return req;
}