From: Jeremy Allison Date: Thu, 20 Oct 2022 22:08:14 +0000 (-0700) Subject: s3: smbd: Add utility function smbd_smb2_is_last_in_compound(). X-Git-Tag: samba-4.16.9~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bfadcc893e6ff2cd7f34896a194e7029fd6a76f5;p=thirdparty%2Fsamba.git s3: smbd: Add utility function smbd_smb2_is_last_in_compound(). Not yet used. Returns true if we're processing the last SMB2 request in a compound. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15172 Signed-off-by: Jeremy Allison Reviewed-by: Ralph Boehme (cherry picked from commit e668c3a82cd566b405c976d45659dd79786948de) --- diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h index eef38f00a4e..efd2032ce1a 100644 --- a/source3/smbd/globals.h +++ b/source3/smbd/globals.h @@ -238,6 +238,7 @@ void smbd_server_disconnect_client_ex(struct smbXsrv_client *client, 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); +bool smbd_smb2_is_last_in_compound(const struct smbd_smb2_request *req); NTSTATUS smbd_add_connection(struct smbXsrv_client *client, int sock_fd, NTTIME now, struct smbXsrv_connection **_xconn); diff --git a/source3/smbd/smb2_server.c b/source3/smbd/smb2_server.c index f4e16cb7da9..f0b4814628b 100644 --- a/source3/smbd/smb2_server.c +++ b/source3/smbd/smb2_server.c @@ -229,6 +229,12 @@ bool smbd_smb2_is_compound(const struct smbd_smb2_request *req) return req->in.vector_count >= (2*SMBD_SMB2_NUM_IOV_PER_REQ); } +bool smbd_smb2_is_last_in_compound(const struct smbd_smb2_request *req) +{ + return (req->current_idx + SMBD_SMB2_NUM_IOV_PER_REQ == + req->in.vector_count); +} + static NTSTATUS smbd_initialize_smb2(struct smbXsrv_connection *xconn, uint64_t expected_seq_low) {