diff options
Diffstat (limited to 'source3/smbd/smb2_read.c')
-rw-r--r-- | source3/smbd/smb2_read.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/source3/smbd/smb2_read.c b/source3/smbd/smb2_read.c index b1866d1481..97f12d582c 100644 --- a/source3/smbd/smb2_read.c +++ b/source3/smbd/smb2_read.c @@ -290,16 +290,16 @@ static struct tevent_req *smbd_smb2_read_send(TALLOC_CTX *mem_ctx, return tevent_req_post(req, ev); } - state->out_data = data_blob_talloc(state, NULL, in_length); - if (in_length > 0 && tevent_req_nomem(state->out_data.data, req)) { - return tevent_req_post(req, ev); - } - state->fsp = fsp; if (IS_IPC(smbreq->conn)) { struct tevent_req *subreq = NULL; + state->out_data = data_blob_talloc(state, NULL, in_length); + if (in_length > 0 && tevent_req_nomem(state->out_data.data, req)) { + return tevent_req_post(req, ev); + } + if (!fsp_is_np(fsp)) { tevent_req_nterror(req, NT_STATUS_FILE_CLOSED); return tevent_req_post(req, ev); @@ -326,7 +326,8 @@ static struct tevent_req *smbd_smb2_read_send(TALLOC_CTX *mem_ctx, status = schedule_smb2_aio_read(fsp->conn, smbreq, fsp, - (char *)state->out_data.data, + state, + &state->out_data, (SMB_OFF_T)in_offset, (size_t)in_length); @@ -363,6 +364,13 @@ static struct tevent_req *smbd_smb2_read_send(TALLOC_CTX *mem_ctx, return tevent_req_post(req, ev); } + /* Ok, read into memory. Allocate the out buffer. */ + state->out_data = data_blob_talloc(state, NULL, in_length); + if (in_length > 0 && tevent_req_nomem(state->out_data.data, req)) { + SMB_VFS_STRICT_UNLOCK(conn, fsp, &lock); + return tevent_req_post(req, ev); + } + nread = read_file(fsp, (char *)state->out_data.data, in_offset, |