From: David Mulder Date: Fri, 25 Mar 2022 19:59:14 +0000 (-0600) Subject: smbd: Move valid_smb_header to smb2_process.c X-Git-Tag: tevent-0.12.0~50 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ed23ce77d940eacb5a2a8e35cba50d7159e185b7;p=thirdparty%2Fsamba.git smbd: Move valid_smb_header to smb2_process.c valid_smb_header is needed for a multi-protocol negotiation. Signed-off-by: David Mulder Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 426e7fdc2d0..35f0c1ef721 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -891,6 +891,7 @@ void smbd_process(struct tevent_context *ev_ctx, struct messaging_context *msg_ctx, int sock_fd, bool interactive); +bool valid_smb_header(const uint8_t *inbuf); /* The following definitions come from smbd/quotas.c */ diff --git a/source3/smbd/smb1_process.c b/source3/smbd/smb1_process.c index 7d568ec7067..cbd0a8aa334 100644 --- a/source3/smbd/smb1_process.c +++ b/source3/smbd/smb1_process.c @@ -276,18 +276,6 @@ out: return (ret > 0); } -bool valid_smb_header(const uint8_t *inbuf) -{ - if (is_encrypted_packet(inbuf)) { - return true; - } - /* - * This used to be (strncmp(smb_base(inbuf),"\377SMB",4) == 0) - * but it just looks weird to call strncmp for this one. - */ - return (IVAL(smb_base(inbuf), 0) == 0x424D53FF); -} - /* Socket functions for smbd packet processing. */ static bool valid_packet_size(size_t len) diff --git a/source3/smbd/smb1_process.h b/source3/smbd/smb1_process.h index 234a19599ab..53074e090f6 100644 --- a/source3/smbd/smb1_process.h +++ b/source3/smbd/smb1_process.h @@ -57,7 +57,6 @@ void process_smb1(struct smbXsrv_connection *xconn, uint8_t *inbuf, size_t nread, size_t unread_bytes, uint32_t seqnum, bool encrypted, struct smb_perfcount_data *deferred_pcd); -bool valid_smb_header(const uint8_t *inbuf); void smbd_echo_init(struct smbXsrv_connection *xconn); void construct_reply(struct smbXsrv_connection *xconn, char *inbuf, int size, size_t unread_bytes, diff --git a/source3/smbd/smb2_process.c b/source3/smbd/smb2_process.c index 81bde560f32..0bc77b97120 100644 --- a/source3/smbd/smb2_process.c +++ b/source3/smbd/smb2_process.c @@ -570,6 +570,18 @@ void reply_outbuf(struct smb_request *req, uint8_t num_words, uint32_t num_bytes req->outbuf = (uint8_t *)outbuf; } +bool valid_smb_header(const uint8_t *inbuf) +{ + if (is_encrypted_packet(inbuf)) { + return true; + } + /* + * This used to be (strncmp(smb_base(inbuf),"\377SMB",4) == 0) + * but it just looks weird to call strncmp for this one. + */ + return (IVAL(smb_base(inbuf), 0) == 0x424D53FF); +} + /**************************************************************************** Process an smb from the client ****************************************************************************/