Skip to content

Commit 366c0c8

Browse files
tobluxvijay-suman
authored andcommitted
smb: server: Fix extension string in ksmbd_extract_shortname()
[ Upstream commit 8e7d178 ] 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: [email protected] Fixes: e2f3448 ("cifsd: add server-side procedures for SMB3") Signed-off-by: Thorsten Blum <[email protected]> Acked-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> (cherry picked from commit 26eb63f732b09f48b539ae272853fa890aec9103) Signed-off-by: Vijayendra Suman <[email protected]>
1 parent 0288e53 commit 366c0c8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/ksmbd/smb_common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ int ksmbd_extract_shortname(struct ksmbd_conn *conn, const char *longname,
508508

509509
p = strrchr(longname, '.');
510510
if (p == longname) { /*name starts with a dot*/
511-
strscpy(extension, "___", strlen("___"));
511+
strscpy(extension, "___", sizeof(extension));
512512
} else {
513513
if (p) {
514514
p++;

0 commit comments

Comments
 (0)