Skip to content

Commit 9cedc58

Browse files
arndbSteve French
authored andcommitted
ksmbd: avoid field overflow warning
clang warns about a possible field overflow in a memcpy: In file included from fs/smb/server/smb_common.c:7: include/linux/fortify-string.h:583:4: error: call to '__write_overflow_field' declared with 'warning' attribute: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror,-Wattribute-warning] __write_overflow_field(p_size_field, size); It appears to interpret the "&out[baselen + 4]" as referring to a single byte of the character array, while the equivalen "out + baselen + 4" is seen as an offset into the array. I don't see that kind of warning elsewhere, so just go with the simple rework. Fixes: e2f3448 ("cifsd: add server-side procedures for SMB3") Signed-off-by: Arnd Bergmann <[email protected]> Acked-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 11d5e20 commit 9cedc58

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/smb/server/smb_common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ int ksmbd_extract_shortname(struct ksmbd_conn *conn, const char *longname,
536536
out[baselen + 3] = PERIOD;
537537

538538
if (dot_present)
539-
memcpy(&out[baselen + 4], extension, 4);
539+
memcpy(out + baselen + 4, extension, 4);
540540
else
541541
out[baselen + 4] = '\0';
542542
smbConvertToUTF16((__le16 *)shortname, out, PATH_MAX,

0 commit comments

Comments
 (0)