smb3.11: replace a 4 with server->vals->header_preamble_size

More cleanup of use of hardcoded 4 byte RFC1001 field size

Signed-off-by: Steve French <smfrench@gmail.com>
Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
Reviewed-by: Ronnie Sahlberg <lsahlber@redhat.com>

+9 -5
+7 -4
fs/cifs/smb2misc.c
··· 94 94 }; 95 95 96 96 #ifdef CONFIG_CIFS_SMB311 97 - static __u32 get_neg_ctxt_len(struct smb2_hdr *hdr, __u32 len, __u32 non_ctxlen) 97 + static __u32 get_neg_ctxt_len(struct smb2_hdr *hdr, __u32 len, __u32 non_ctxlen, 98 + size_t hdr_preamble_size) 98 99 { 99 100 __u16 neg_count; 100 101 __u32 nc_offset, size_of_pad_before_neg_ctxts; ··· 109 108 110 109 /* Make sure that negotiate contexts start after gss security blob */ 111 110 nc_offset = le32_to_cpu(pneg_rsp->NegotiateContextOffset); 112 - if (nc_offset < non_ctxlen - 4 /* RFC1001 len field */) { 111 + if (nc_offset < non_ctxlen - hdr_preamble_size /* RFC1001 len */) { 113 112 printk_once(KERN_WARNING "invalid negotiate context offset\n"); 114 113 return 0; 115 114 } 116 - size_of_pad_before_neg_ctxts = nc_offset - (non_ctxlen - 4); 115 + size_of_pad_before_neg_ctxts = nc_offset - 116 + (non_ctxlen - hdr_preamble_size); 117 117 118 118 /* Verify that at least minimal negotiate contexts fit within frame */ 119 119 if (len < nc_offset + (neg_count * sizeof(struct smb2_neg_context))) { ··· 237 235 238 236 #ifdef CONFIG_CIFS_SMB311 239 237 if (shdr->Command == SMB2_NEGOTIATE) 240 - clc_len += get_neg_ctxt_len(hdr, len, clc_len); 238 + clc_len += get_neg_ctxt_len(hdr, len, clc_len, 239 + srvr->vals->header_preamble_size); 241 240 #endif /* SMB311 */ 242 241 if (srvr->vals->header_preamble_size + len != clc_len) { 243 242 cifs_dbg(FYI, "Calculated size %u length %zu mismatch mid %llu\n",
+2 -1
fs/cifs/smb2pdu.c
··· 474 474 if (len_of_ctxts < sizeof(struct smb2_neg_context)) 475 475 break; 476 476 477 - pctx = (struct smb2_neg_context *)(offset + 4 + (char *)rsp); 477 + pctx = (struct smb2_neg_context *)(offset + 478 + server->vals->header_preamble_size + (char *)rsp); 478 479 clen = le16_to_cpu(pctx->DataLength); 479 480 if (clen > len_of_ctxts) 480 481 break;