]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
smb: fix invalid username check in smb3_fs_context_parse_param()
authorYiqi Sun <sunyiqixm@gmail.com>
Tue, 11 Nov 2025 07:05:39 +0000 (15:05 +0800)
committerSteve French <stfrench@microsoft.com>
Tue, 11 Nov 2025 16:01:47 +0000 (10:01 -0600)
Since the maximum return value of strnlen(..., CIFS_MAX_USERNAME_LEN)
is CIFS_MAX_USERNAME_LEN, length check in smb3_fs_context_parse_param()
is always FALSE and invalid.

Fix the comparison in if statement.

Signed-off-by: Yiqi Sun <sunyiqixm@gmail.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/fs_context.c

index c2d5bb23040cf2835229f05b39ee9f80d74d451b..0f894d09157b919e5bdcb17a6ee5dc495d8e034b 100644 (file)
@@ -1470,7 +1470,7 @@ static int smb3_fs_context_parse_param(struct fs_context *fc,
                        break;
                }
 
-               if (strnlen(param->string, CIFS_MAX_USERNAME_LEN) >
+               if (strnlen(param->string, CIFS_MAX_USERNAME_LEN) ==
                    CIFS_MAX_USERNAME_LEN) {
                        pr_warn("username too long\n");
                        goto cifs_parse_mount_err;