Skip to content

Commit 819f916

Browse files
committed
cifs: clarify SMB1 code for UnixCreateHardLink
Coverity 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). This doesn't change the address but makes it slightly clearer. Addresses-Coverity: 711529 ("Out of bounds read") Reviewed-by: Ronnie Sahlberg <lsahlber@redhat.com> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 01cf308 commit 819f916

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

fs/cifs/cifspdu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1785,6 +1785,7 @@ struct smb_com_transaction2_sfi_req {
17851785
__u16 Fid;
17861786
__le16 InformationLevel;
17871787
__u16 Reserved4;
1788+
__u8 payload[];
17881789
} __attribute__((packed));
17891790

17901791
struct smb_com_transaction2_sfi_rsp {

fs/cifs/cifssmb.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3009,7 +3009,8 @@ CIFSUnixCreateHardLink(const unsigned int xid, struct cifs_tcon *tcon,
30093009
InformationLevel) - 4;
30103010
offset = param_offset + params;
30113011

3012-
data_offset = (char *) (&pSMB->hdr.Protocol) + offset;
3012+
/* SMB offsets are from the beginning of SMB which is 4 bytes in, after RFC1001 field */
3013+
data_offset = (char *)pSMB + offset + 4;
30133014
if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
30143015
name_len_target =
30153016
cifsConvertToUTF16((__le16 *) data_offset, fromName,

0 commit comments

Comments
 (0)