From: Thorsten Blum Date: Wed, 13 Aug 2025 13:32:18 +0000 (-0400) Subject: smb: server: Fix extension string in ksmbd_extract_shortname() X-Git-Tag: v5.15.190~123 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=26eb63f732b09f48b539ae272853fa890aec9103;p=thirdparty%2Fkernel%2Fstable.git smb: server: Fix extension string in ksmbd_extract_shortname() [ Upstream commit 8e7d178d06e8937454b6d2f2811fa6a15656a214 ] 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 Acked-by: Namjae Jeon Signed-off-by: Steve French Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/ksmbd/smb_common.c b/fs/ksmbd/smb_common.c index e90a1e8c1951d..0438a634f4c21 100644 --- a/fs/ksmbd/smb_common.c +++ b/fs/ksmbd/smb_common.c @@ -508,7 +508,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++;