s3:smbd:smb2: simplify smbd_smb2_request_validate() and smbd_smb2_request_dispatch()
authorMichael Adam <obnox@samba.org>
Fri, 21 Sep 2012 19:43:36 +0000 (21:43 +0200)
committerMichael Adam <obnox@samba.org>
Sat, 22 Sep 2012 08:18:58 +0000 (10:18 +0200)
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>

source3/smbd/globals.h
source3/smbd/smb2_server.c

index 74e42c77afec6d393a69e23fe66a0141ff6f4a0f..9bc6b175b5addf46aaa901ba23a823b8f4989d2b 100644 (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.
index 8443ed775a889f77db721584ca303cb8faf514f9..77f25a9a82139c771ba2bf45d7430502d769914b 100644 (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;
        }