]> Git Repo - linux.git/commitdiff
ksmbd: avoid field overflow warning
authorArnd Bergmann <[email protected]>
Mon, 19 Jun 2023 08:19:38 +0000 (10:19 +0200)
committerSteve French <[email protected]>
Thu, 29 Jun 2023 03:58:28 +0000 (22:58 -0500)
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: e2f34481b24d ("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]>
fs/smb/server/smb_common.c

index b51f431ade01bdf3af3e686a0d5b2a5ee9644d2a..ef20f63e55e686e08e3535ab8775414a3abcf9cd 100644 (file)
@@ -536,7 +536,7 @@ int ksmbd_extract_shortname(struct ksmbd_conn *conn, const char *longname,
        out[baselen + 3] = PERIOD;
 
        if (dot_present)
-               memcpy(&out[baselen + 4], extension, 4);
+               memcpy(out + baselen + 4, extension, 4);
        else
                out[baselen + 4] = '\0';
        smbConvertToUTF16((__le16 *)shortname, out, PATH_MAX,
This page took 0.050739 seconds and 4 git commands to generate.