From 29b3601c028b8861102b1d988285c78fc17f3b8e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 6 Sep 2011 14:01:43 +0200 Subject: [PATCH] s3:smb2_server: use smbd_smb2_request_verify_sizes() in smb2_ioctl.c metze --- source3/smbd/smb2_ioctl.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/source3/smbd/smb2_ioctl.c b/source3/smbd/smb2_ioctl.c index abb1905ba09..491c3fd9cc0 100644 --- a/source3/smbd/smb2_ioctl.c +++ b/source3/smbd/smb2_ioctl.c @@ -41,11 +41,9 @@ static NTSTATUS smbd_smb2_ioctl_recv(struct tevent_req *req, static void smbd_smb2_request_ioctl_done(struct tevent_req *subreq); NTSTATUS smbd_smb2_request_process_ioctl(struct smbd_smb2_request *req) { - const uint8_t *inhdr; + NTSTATUS status; const uint8_t *inbody; int i = req->current_idx; - size_t expected_body_size = 0x39; - size_t body_size; uint32_t in_ctl_code; uint64_t in_file_id_persistent; uint64_t in_file_id_volatile; @@ -56,18 +54,12 @@ NTSTATUS smbd_smb2_request_process_ioctl(struct smbd_smb2_request *req) uint32_t in_flags; struct tevent_req *subreq; - inhdr = (const uint8_t *)req->in.vector[i+0].iov_base; - if (req->in.vector[i+1].iov_len != (expected_body_size & 0xFFFFFFFE)) { - return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER); + status = smbd_smb2_request_verify_sizes(req, 0x39); + if (!NT_STATUS_IS_OK(status)) { + return smbd_smb2_request_error(req, status); } - inbody = (const uint8_t *)req->in.vector[i+1].iov_base; - body_size = SVAL(inbody, 0x00); - if (body_size != expected_body_size) { - return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER); - } - in_ctl_code = IVAL(inbody, 0x04); in_file_id_persistent = BVAL(inbody, 0x08); in_file_id_volatile = BVAL(inbody, 0x10); @@ -76,7 +68,7 @@ NTSTATUS smbd_smb2_request_process_ioctl(struct smbd_smb2_request *req) in_max_output_length = IVAL(inbody, 0x2C); in_flags = IVAL(inbody, 0x30); - if (in_input_offset != (SMB2_HDR_BODY + (body_size & 0xFFFFFFFE))) { + if (in_input_offset != (SMB2_HDR_BODY + req->in.vector[i+1].iov_len)) { return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER); }