Skip to contentSkip to conversation

cifs: silence compiler warnings showing up with gcc-8.0.0

PATCH Applied Arnd Bergmann 2 participants 2 messages Feb 2, 2018 – Feb 4, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cifs: silence compiler warnings showing up with gcc-8.0.0

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")
---
 fs/cifs/cifssmb.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
fs/cifs/cifssmb.c +1 -3
index 72d71703f1e8..78bc86c315ec 100644
@@ -6343,9 +6343,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;
Signature · 1 line
2.9.0
Applied
#1 lore raw

merged into cifs-2.6.git for-next

Quoted 37 lines · Arnd Bergmann

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")
---
 fs/cifs/cifssmb.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
fs/cifs/cifssmb.c +1 -4
index 72d71703f1e8..78bc86c315ec 100644
@@ -6343,9 +6343,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;
--

2.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 3 lines
Thanks,

Steve