Skip to content

Commit d4dc277

Browse files
committed
CIFS: Clarify SMB1 code for POSIX Lock
Coverity also complains about the way we calculate the offset (starting from the address of a 4 byte array within the header structure rather than from the beginning of the struct plus 4 bytes) for SMB1 PosixLock. This changeset doesn't change the address but makes it slightly clearer. Addresses-Coverity: 711520 ("Out of bounds write") Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent f371793 commit d4dc277

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

fs/cifs/cifssmb.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2537,8 +2537,9 @@ CIFSSMBPosixLock(const unsigned int xid, struct cifs_tcon *tcon,
25372537
pSMB->TotalDataCount = pSMB->DataCount;
25382538
pSMB->TotalParameterCount = pSMB->ParameterCount;
25392539
pSMB->ParameterOffset = cpu_to_le16(param_offset);
2540+
/* SMB offsets are from the beginning of SMB which is 4 bytes in, after RFC1001 field */
25402541
parm_data = (struct cifs_posix_lock *)
2541-
(((char *) &pSMB->hdr.Protocol) + offset);
2542+
(((char *)pSMB) + offset + 4);
25422543

25432544
parm_data->lock_type = cpu_to_le16(lock_type);
25442545
if (waitFlag) {

0 commit comments

Comments
 (0)