mirror of
https://github.com/samba-team/samba.git
synced 2025-08-04 08:22:08 +03:00
libcli/smb: correctly handle STATUS_BUFFER_OVERFLOW in smb2cli_read*
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11623 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
committed by
Jeremy Allison
parent
91e12e04fc
commit
b47bfce678
@ -29,6 +29,7 @@ struct smb2cli_read_state {
|
|||||||
struct iovec *recv_iov;
|
struct iovec *recv_iov;
|
||||||
uint8_t *data;
|
uint8_t *data;
|
||||||
uint32_t data_length;
|
uint32_t data_length;
|
||||||
|
bool out_valid;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void smb2cli_read_done(struct tevent_req *subreq);
|
static void smb2cli_read_done(struct tevent_req *subreq);
|
||||||
@ -105,8 +106,12 @@ static void smb2cli_read_done(struct tevent_req *subreq)
|
|||||||
status = smb2cli_req_recv(subreq, state, &iov,
|
status = smb2cli_req_recv(subreq, state, &iov,
|
||||||
expected, ARRAY_SIZE(expected));
|
expected, ARRAY_SIZE(expected));
|
||||||
TALLOC_FREE(subreq);
|
TALLOC_FREE(subreq);
|
||||||
if (tevent_req_nterror(req, status)) {
|
if (NT_STATUS_EQUAL(status, STATUS_BUFFER_OVERFLOW)) {
|
||||||
return;
|
/* no error */
|
||||||
|
} else {
|
||||||
|
if (tevent_req_nterror(req, status)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data_offset = CVAL(iov[1].iov_base, 2);
|
data_offset = CVAL(iov[1].iov_base, 2);
|
||||||
@ -120,6 +125,13 @@ static void smb2cli_read_done(struct tevent_req *subreq)
|
|||||||
|
|
||||||
state->recv_iov = iov;
|
state->recv_iov = iov;
|
||||||
state->data = (uint8_t *)iov[2].iov_base;
|
state->data = (uint8_t *)iov[2].iov_base;
|
||||||
|
|
||||||
|
state->out_valid = true;
|
||||||
|
|
||||||
|
if (tevent_req_nterror(req, status)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
tevent_req_done(req);
|
tevent_req_done(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,15 +141,19 @@ NTSTATUS smb2cli_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
|
|||||||
struct smb2cli_read_state *state =
|
struct smb2cli_read_state *state =
|
||||||
tevent_req_data(req,
|
tevent_req_data(req,
|
||||||
struct smb2cli_read_state);
|
struct smb2cli_read_state);
|
||||||
NTSTATUS status;
|
NTSTATUS status = NT_STATUS_OK;
|
||||||
|
|
||||||
if (tevent_req_is_nterror(req, &status)) {
|
if (tevent_req_is_nterror(req, &status) && !state->out_valid) {
|
||||||
|
*data_length = 0;
|
||||||
|
*data = NULL;
|
||||||
|
tevent_req_received(req);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
talloc_steal(mem_ctx, state->recv_iov);
|
talloc_steal(mem_ctx, state->recv_iov);
|
||||||
*data_length = state->data_length;
|
*data_length = state->data_length;
|
||||||
*data = state->data;
|
*data = state->data;
|
||||||
return NT_STATUS_OK;
|
tevent_req_received(req);
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS smb2cli_read(struct smbXcli_conn *conn,
|
NTSTATUS smb2cli_read(struct smbXcli_conn *conn,
|
||||||
|
Reference in New Issue
Block a user