diff options
author | Ronnie Sahlberg <lsahlber@redhat.com> | 2018-04-22 15:30:12 -0600 |
---|---|---|
committer | Steve French <stfrench@microsoft.com> | 2018-05-27 17:56:35 -0500 |
commit | 9ec672bd17131fe26c966960a573a76fdb1da323 (patch) | |
tree | 92fe6dc479fbaca3f2e260a3a5bf6f5b1f750382 /fs/cifs/smb2misc.c | |
parent | 14547f7d74c4a2583214693f69d45374b8028649 (diff) | |
download | linux-9ec672bd17131fe26c966960a573a76fdb1da323.tar.bz2 |
cifs: update calc_size to take a server argument
and change the smb2 version to take heder_preamble_size into account
instead of hardcoding it as 4 bytes.
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs/cifs/smb2misc.c')
-rw-r--r-- | fs/cifs/smb2misc.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/fs/cifs/smb2misc.c b/fs/cifs/smb2misc.c index 68ea8491c160..f7f3ad760401 100644 --- a/fs/cifs/smb2misc.c +++ b/fs/cifs/smb2misc.c @@ -233,7 +233,7 @@ smb2_check_message(char *buf, unsigned int length, struct TCP_Server_Info *srvr) return 1; } - clc_len = smb2_calc_size(hdr); + clc_len = smb2_calc_size(hdr, srvr); #ifdef CONFIG_CIFS_SMB311 if (shdr->Command == SMB2_NEGOTIATE) @@ -403,7 +403,7 @@ smb2_get_data_area_len(int *off, int *len, struct smb2_hdr *hdr) * portion, the number of word parameters and the data portion of the message. */ unsigned int -smb2_calc_size(void *buf) +smb2_calc_size(void *buf, struct TCP_Server_Info *srvr) { struct smb2_pdu *pdu = (struct smb2_pdu *)buf; struct smb2_hdr *hdr = &pdu->hdr; @@ -411,7 +411,7 @@ smb2_calc_size(void *buf) int offset; /* the offset from the beginning of SMB to data area */ int data_length; /* the length of the variable length data area */ /* Structure Size has already been checked to make sure it is 64 */ - int len = 4 + le16_to_cpu(shdr->StructureSize); + int len = srvr->vals->header_preamble_size + le16_to_cpu(shdr->StructureSize); /* * StructureSize2, ie length of fixed parameter area has already @@ -433,12 +433,12 @@ smb2_calc_size(void *buf) * so we must add one to the calculation (and 4 to account for * the size of the RFC1001 hdr. */ - if (offset + 4 + 1 < len) { - cifs_dbg(VFS, "data area offset %d overlaps SMB2 header %d\n", - offset + 4 + 1, len); + if (offset + srvr->vals->header_preamble_size + 1 < len) { + cifs_dbg(VFS, "data area offset %zu overlaps SMB2 header %d\n", + offset + srvr->vals->header_preamble_size + 1, len); data_length = 0; } else { - len = 4 + offset + data_length; + len = srvr->vals->header_preamble_size + offset + data_length; } } calc_size_exit: |