smbd: Move check for SMB2 compound request to new function
authorChristof Schmitt <cs@samba.org>
Fri, 22 Sep 2017 00:41:25 +0000 (17:41 -0700)
committerKarolin Seeger <kseeger@samba.org>
Wed, 1 Nov 2017 09:49:25 +0000 (10:49 +0100)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13047

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit cfa2c3083080016a1288474b8879039db4dbf6b1)

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

index ae5ecf40138910317037aa2bfae94956d3b4b349..78f1260909d4ab7c4db0b4682b502c962796e04d 100644 (file)
@@ -225,6 +225,7 @@ void smbd_server_connection_terminate_ex(struct smbXsrv_connection *xconn,
 
 const char *smb2_opcode_name(uint16_t opcode);
 bool smbd_is_smb2_header(const uint8_t *inbuf, size_t size);
+bool smbd_smb2_is_compound(const struct smbd_smb2_request *req);
 
 NTSTATUS smbd_add_connection(struct smbXsrv_client *client, int sock_fd,
                             struct smbXsrv_connection **_xconn);
index ecedf1ef0bf14acf57e60c770024eae200899c9e..273c56cf35261b37d9ba61c19f6755a3c800eb32 100644 (file)
@@ -350,7 +350,7 @@ static NTSTATUS schedule_smb2_sendfile_read(struct smbd_smb2_request *smb2req,
        if (!lp__use_sendfile(SNUM(fsp->conn)) ||
            smb2req->do_signing ||
            smb2req->do_encryption ||
-           smb2req->in.vector_count >= (2*SMBD_SMB2_NUM_IOV_PER_REQ) ||
+           smbd_smb2_is_compound(smb2req) ||
            (fsp->base_fsp != NULL) ||
            (fsp->wcp != NULL) ||
            (!S_ISREG(fsp->fsp_name->st.st_ex_mode)) ||
index d95631f2ff4d56407f0a59450ea28bcdceb6ede9..68a024f4ec8103eb3c4faa6fa1d9f0f59a9b171e 100644 (file)
@@ -204,6 +204,11 @@ bool smbd_is_smb2_header(const uint8_t *inbuf, size_t size)
        return true;
 }
 
+bool smbd_smb2_is_compound(const struct smbd_smb2_request *req)
+{
+       return req->in.vector_count >= (2*SMBD_SMB2_NUM_IOV_PER_REQ);
+}
+
 static NTSTATUS smbd_initialize_smb2(struct smbXsrv_connection *xconn,
                                     uint64_t expected_seq_low)
 {