]> git.ipfire.org Git - thirdparty/linux.git/commit - fs/smb/server/vfs.c
ksmbd: make utf-8 file name comparison work in __caseless_lookup()
authorAtte Heikkilä <atteh.mailbox@gmail.com>
Tue, 27 Sep 2022 21:57:21 +0000 (00:57 +0300)
committerSteve French <stfrench@microsoft.com>
Wed, 5 Oct 2022 06:15:44 +0000 (01:15 -0500)
commitdbab80e2071ad8c702e50dab43326608a127d27b
treea380652e4821b2f52af84ef4cb766768b18ae949
parent7c88c1e0ab1704bacb751341ee6431c3be34b834
ksmbd: make utf-8 file name comparison work in __caseless_lookup()

Case-insensitive file name lookups with __caseless_lookup() use
strncasecmp() for file name comparison. strncasecmp() assumes an
ISO8859-1-compatible encoding, which is not the case here as UTF-8
is always used. As such, use of strncasecmp() here produces correct
results only if both strings use characters in the ASCII range only.
Fix this by using utf8_strncasecmp() if CONFIG_UNICODE is set. On
failure or if CONFIG_UNICODE is not set, fallback to strncasecmp().
Also, as we are adding an include for `linux/unicode.h', include it
in `fs/ksmbd/connection.h' as well since it should be explicit there.

Signed-off-by: Atte Heikkilä <atteh.mailbox@gmail.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/ksmbd/connection.h
fs/ksmbd/vfs.c
fs/ksmbd/vfs.h