Skip to content

Commit e3973ea

Browse files
committed
CIFS: Clarify SMB1 code for SetFileSize
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 setting the file size using SMB1. This changeset doesn't change the address but makes it slightly clearer. Addresses-Coverity: 711525 ("Out of bounds write") Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 90810c2 commit e3973ea

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

fs/cifs/cifssmb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5628,9 +5628,9 @@ CIFSSMBSetFileSize(const unsigned int xid, struct cifs_tcon *tcon,
56285628
pSMB->TotalDataCount = pSMB->DataCount;
56295629
pSMB->TotalParameterCount = pSMB->ParameterCount;
56305630
pSMB->ParameterOffset = cpu_to_le16(param_offset);
5631+
/* SMB offsets are from the beginning of SMB which is 4 bytes in, after RFC1001 field */
56315632
parm_data =
5632-
(struct file_end_of_file_info *) (((char *) &pSMB->hdr.Protocol)
5633-
+ offset);
5633+
(struct file_end_of_file_info *)(((char *)pSMB) + offset + 4);
56345634
pSMB->DataOffset = cpu_to_le16(offset);
56355635
parm_data->FileSize = cpu_to_le64(size);
56365636
pSMB->Fid = cfile->fid.netfid;

0 commit comments

Comments
 (0)