NTSTATUS smbd_smb2_request_process_read(struct smbd_smb2_request *req) { NTSTATUS status; const uint8_t *inhdr; const uint8_t *inbody; int i = req->current_idx; uint32_t in_smbpid; uint32_t in_length; uint64_t in_offset; uint64_t in_file_id_persistent; uint64_t in_file_id_volatile; uint32_t in_minimum_count; uint32_t in_remaining_bytes; struct tevent_req *subreq; status = smbd_smb2_request_verify_sizes(req, 0x31); if (!NT_STATUS_IS_OK(status)) { return smbd_smb2_request_error(req, status); } inhdr = (const uint8_t *)req->in.vector[i+0].iov_base; inbody = (const uint8_t *)req->in.vector[i+1].iov_base; in_smbpid = IVAL(inhdr, SMB2_HDR_PID); in_length = IVAL(inbody, 0x04); in_offset = BVAL(inbody, 0x08); in_file_id_persistent = BVAL(inbody, 0x10); in_file_id_volatile = BVAL(inbody, 0x18); in_minimum_count = IVAL(inbody, 0x20); in_remaining_bytes = IVAL(inbody, 0x28); /* check the max read size */ if (in_length > lp_smb2_max_read()) { DEBUG(0,("here:%s: 0x%08X: 0x%08X\n", __location__, in_length, lp_smb2_max_read())); return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER); } if (req->compat_chain_fsp) { /* skip check */ } else if (in_file_id_persistent != in_file_id_volatile) { return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED); } subreq = smbd_smb2_read_send(req, req->sconn->smb2.event_ctx, req, in_smbpid, in_file_id_volatile, in_length, in_offset, in_minimum_count, in_remaining_bytes); if (subreq == NULL) { return smbd_smb2_request_error(req, NT_STATUS_NO_MEMORY); } tevent_req_set_callback(subreq, smbd_smb2_request_read_done, req); return smbd_smb2_request_pending_queue(req, subreq); }
NTSTATUS smbd_smb2_request_process_read(struct smbd_smb2_request *req) { struct smbXsrv_connection *xconn = req->xconn; NTSTATUS status; const uint8_t *inbody; uint32_t in_length; uint64_t in_offset; uint64_t in_file_id_persistent; uint64_t in_file_id_volatile; struct files_struct *in_fsp; uint32_t in_minimum_count; uint32_t in_remaining_bytes; struct tevent_req *subreq; status = smbd_smb2_request_verify_sizes(req, 0x31); if (!NT_STATUS_IS_OK(status)) { return smbd_smb2_request_error(req, status); } inbody = SMBD_SMB2_IN_BODY_PTR(req); in_length = IVAL(inbody, 0x04); in_offset = BVAL(inbody, 0x08); in_file_id_persistent = BVAL(inbody, 0x10); in_file_id_volatile = BVAL(inbody, 0x18); in_minimum_count = IVAL(inbody, 0x20); in_remaining_bytes = IVAL(inbody, 0x28); /* check the max read size */ if (in_length > xconn->smb2.server.max_read) { DEBUG(2,("smbd_smb2_request_process_read: " "client ignored max read: %s: 0x%08X: 0x%08X\n", __location__, in_length, xconn->smb2.server.max_read)); return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER); } status = smbd_smb2_request_verify_creditcharge(req, in_length); if (!NT_STATUS_IS_OK(status)) { return smbd_smb2_request_error(req, status); } in_fsp = file_fsp_smb2(req, in_file_id_persistent, in_file_id_volatile); if (in_fsp == NULL) { return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED); } subreq = smbd_smb2_read_send(req, req->sconn->ev_ctx, req, in_fsp, in_length, in_offset, in_minimum_count, in_remaining_bytes); if (subreq == NULL) { return smbd_smb2_request_error(req, NT_STATUS_NO_MEMORY); } tevent_req_set_callback(subreq, smbd_smb2_request_read_done, req); return smbd_smb2_request_pending_queue(req, subreq, 500); }