cifs: silence compiler warnings showing up with gcc-8.0.0
authorArnd Bergmann <arnd@arndb.de>
Fri, 2 Feb 2018 15:48:47 +0000 (16:48 +0100)
committerBen Hutchings <ben@decadent.org.uk>
Sat, 16 Jun 2018 21:22:11 +0000 (22:22 +0100)
commit ade7db991b47ab3016a414468164f4966bd08202 upstream.

This bug was fixed before, but came up again with the latest
compiler in another function:

fs/cifs/cifssmb.c: In function 'CIFSSMBSetEA':
fs/cifs/cifssmb.c:6362:3: error: 'strncpy' offset 8 is out of the bounds [0, 4] [-Werror=array-bounds]
   strncpy(parm_data->list[0].name, ea_name, name_len);

Let's apply the same fix that was used for the other instances.

Fixes: b2a3ad9ca502 ("cifs: silence compiler warnings showing up with gcc-4.7.0")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Steve French <smfrench@gmail.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
fs/cifs/cifssmb.c

index 36344cb2f1ca4dc3839738f18cb53f41d1ef0d4b..669d1a0a7358cf8988c5c2a6ae185ef3fe62ebb5 100644 (file)
@@ -6366,9 +6366,7 @@ CIFSSMBSetEA(const unsigned int xid, struct cifs_tcon *tcon,
        pSMB->InformationLevel =
                cpu_to_le16(SMB_SET_FILE_EA);
 
-       parm_data =
-               (struct fealist *) (((char *) &pSMB->hdr.Protocol) +
-                                      offset);
+       parm_data = (void *)pSMB + offsetof(struct smb_hdr, Protocol) + offset;
        pSMB->ParameterOffset = cpu_to_le16(param_offset);
        pSMB->DataOffset = cpu_to_le16(offset);
        pSMB->SetupCount = 1;