1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-12 09:18:10 +03:00

s3:smbd:smb2: simplify smbd_smb2_request_validate() and smbd_smb2_request_dispatch()

removes unnneccary checks/assignments for compound_related and next_status
and duplicate setting of error status.

And remove (now) unused next_status from struct smbd_smb2_request.

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
This commit is contained in:
Michael Adam 2012-09-21 21:43:36 +02:00
parent 27d38b5c27
commit 1ae6f9c626
2 changed files with 3 additions and 51 deletions

View File

@ -486,8 +486,6 @@ struct smbd_smb2_request {
struct smb_request *smb1req;
struct files_struct *compat_chain_fsp;
NTSTATUS next_status;
/*
* The sub request for async backend calls.
* This is used for SMB2 Cancel.

View File

@ -713,7 +713,6 @@ static NTSTATUS smbd_smb2_request_validate(struct smbd_smb2_request *req)
struct iovec *hdr = SMBD_SMB2_IDX_HDR_IOV(req,in,idx);
struct iovec *body = SMBD_SMB2_IDX_BODY_IOV(req,in,idx);
const uint8_t *inhdr = NULL;
uint32_t flags;
if (hdr->iov_len != SMB2_HDR_BODY) {
return NT_STATUS_INVALID_PARAMETER;
@ -733,50 +732,6 @@ static NTSTATUS smbd_smb2_request_validate(struct smbd_smb2_request *req)
if (!smb2_validate_message_id(req->sconn, inhdr)) {
return NT_STATUS_INVALID_PARAMETER;
}
flags = IVAL(inhdr, SMB2_HDR_FLAGS);
if (idx < SMBD_SMB2_NUM_IOV_PER_REQ) {
/*
* the 1st request should never have the
* SMB2_HDR_FLAG_CHAINED flag set
*/
if (flags & SMB2_HDR_FLAG_CHAINED) {
req->next_status = NT_STATUS_INVALID_PARAMETER;
return NT_STATUS_OK;
}
} else if (idx < 2*SMBD_SMB2_NUM_IOV_PER_REQ) {
/*
* the 2nd request triggers related vs. unrelated
* compounded requests
*/
if (flags & SMB2_HDR_FLAG_CHAINED) {
req->compound_related = true;
}
} else {
#if 0
/*
* It seems the this tests are wrong
* see the SMB2-COMPOUND test
*/
/*
* all other requests should match the 2nd one
*/
if (flags & SMB2_HDR_FLAG_CHAINED) {
if (!req->compound_related) {
req->next_status =
NT_STATUS_INVALID_PARAMETER;
return NT_STATUS_OK;
}
} else {
if (req->compound_related) {
req->next_status =
NT_STATUS_INVALID_PARAMETER;
return NT_STATUS_OK;
}
}
#endif
}
}
return NT_STATUS_OK;
@ -2003,9 +1958,6 @@ NTSTATUS smbd_smb2_request_dispatch(struct smbd_smb2_request *req)
* This check is mostly for giving the correct error code
* for compounded requests.
*/
if (!NT_STATUS_IS_OK(req->next_status)) {
return smbd_smb2_request_error(req, req->next_status);
}
if (!NT_STATUS_IS_OK(session_status)) {
return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER);
}
@ -2061,7 +2013,8 @@ NTSTATUS smbd_smb2_request_dispatch(struct smbd_smb2_request *req)
return smbd_smb2_request_error(req, NT_STATUS_ACCESS_DENIED);
}
if (req->compound_related) {
if (flags & SMB2_HDR_FLAG_CHAINED) {
req->compound_related = true;
req->sconn->smb2.compound_related_in_progress = true;
}
@ -2425,6 +2378,7 @@ static NTSTATUS smbd_smb2_request_reply(struct smbd_smb2_request *req)
}
if (req->compound_related) {
req->compound_related = false;
req->sconn->smb2.compound_related_in_progress = false;
}