* [PATCH v2] smb: server: Fix extension string in ksmbd_extract_shortname()
@ 2025-08-06 1:03 Thorsten Blum
2025-08-06 2:41 ` Namjae Jeon
0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2025-08-06 1:03 UTC (permalink / raw)
To: Namjae Jeon, Steve French, Sergey Senozhatsky, Tom Talpey,
Ronnie Sahlberg, Hyunchul Lee
Cc: Thorsten Blum, stable, Steve French, Namjae Jeon, linux-cifs,
linux-kernel
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>
---
Changes in v2:
- Use three parameter variant of strscpy() for easier backporting
- Link to v1: https://lore.kernel.org/lkml/20250805221424.57890-1-thorsten.blum@linux.dev/
---
fs/smb/server/smb_common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/smb/server/smb_common.c b/fs/smb/server/smb_common.c
index 425c756bcfb8..b23203a1c286 100644
--- a/fs/smb/server/smb_common.c
+++ b/fs/smb/server/smb_common.c
@@ -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++;
--
2.50.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] smb: server: Fix extension string in ksmbd_extract_shortname()
2025-08-06 1:03 [PATCH v2] smb: server: Fix extension string in ksmbd_extract_shortname() Thorsten Blum
@ 2025-08-06 2:41 ` Namjae Jeon
0 siblings, 0 replies; 2+ messages in thread
From: Namjae Jeon @ 2025-08-06 2:41 UTC (permalink / raw)
To: Thorsten Blum
Cc: Steve French, Sergey Senozhatsky, Tom Talpey, Ronnie Sahlberg,
Hyunchul Lee, stable, Steve French, Namjae Jeon, linux-cifs,
linux-kernel
On Wed, Aug 6, 2025 at 10:04 AM Thorsten Blum <thorsten.blum@linux.dev> wrote:
>
> 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>
Applied it to #ksmbd-for-next-next.
Thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-06 2:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-06 1:03 [PATCH v2] smb: server: Fix extension string in ksmbd_extract_shortname() Thorsten Blum
2025-08-06 2:41 ` Namjae Jeon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).