]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
smb: server: Fix extension string in ksmbd_extract_shortname()
authorThorsten Blum <thorsten.blum@linux.dev>
Wed, 6 Aug 2025 01:03:49 +0000 (03:03 +0200)
committerSteve French <stfrench@microsoft.com>
Thu, 7 Aug 2025 23:23:12 +0000 (18:23 -0500)
In ksmbd_extract_shortname(), strscpy() is incorrectly called with the
length of the source string (excluding the NUL terminator) rather than
the size of the destination buffer. This results in "__" being copied
to 'extension' rather than "___" (two underscores instead of three).

Use the destination buffer size instead to ensure that the string "___"
(three underscores) is copied correctly.

Cc: stable@vger.kernel.org
Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3")
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/server/smb_common.c

index 425c756bcfb8628ebc023ec1c22423aafdfba124..b23203a1c2865a73b5bb486c5ad1b9d5ad35ff1f 100644 (file)
@@ -515,7 +515,7 @@ int ksmbd_extract_shortname(struct ksmbd_conn *conn, const char *longname,
 
        p = strrchr(longname, '.');
        if (p == longname) { /*name starts with a dot*/
-               strscpy(extension, "___", strlen("___"));
+               strscpy(extension, "___", sizeof(extension));
        } else {
                if (p) {
                        p++;