From 13da33f236048ab6aa63d266819e3a4373e7b43d Mon Sep 17 00:00:00 2001 From: Christof Schmitt Date: Thu, 21 Sep 2017 17:41:25 -0700 Subject: [PATCH] smbd: Move check for SMB2 compound request to new function BUG: https://bugzilla.samba.org/show_bug.cgi?id=13047 Signed-off-by: Christof Schmitt Reviewed-by: Jeremy Allison (cherry picked from commit cfa2c3083080016a1288474b8879039db4dbf6b1) --- source3/smbd/globals.h | 1 + source3/smbd/smb2_read.c | 2 +- source3/smbd/smb2_server.c | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h index 67d3a892d58..d3b9800f590 100644 --- a/source3/smbd/globals.h +++ b/source3/smbd/globals.h @@ -224,6 +224,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); diff --git a/source3/smbd/smb2_read.c b/source3/smbd/smb2_read.c index 89527f38748..c28aaae4ecf 100644 --- a/source3/smbd/smb2_read.c +++ b/source3/smbd/smb2_read.c @@ -345,7 +345,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)) || diff --git a/source3/smbd/smb2_server.c b/source3/smbd/smb2_server.c index acaa0126dd8..e6bc7536938 100644 --- a/source3/smbd/smb2_server.c +++ b/source3/smbd/smb2_server.c @@ -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) { -- 2.47.2