]> git.baikalelectronics.ru Git - kernel.git/commit
ksmbd: casefold utf-8 share names and fix ascii lowercase conversion
authorAtte Heikkilä <atteh.mailbox@gmail.com>
Thu, 15 Sep 2022 13:49:11 +0000 (22:49 +0900)
committerSteve French <stfrench@microsoft.com>
Wed, 5 Oct 2022 06:15:37 +0000 (01:15 -0500)
commitad7ce26c89d56f9b3b1bdf4c1b82ea163e081539
treedf57c1e9c146006b13183ba9e8a117accdfc02c7
parent837fba1e81436988fc1ece3edf11d545a6bf38f5
ksmbd: casefold utf-8 share names and fix ascii lowercase conversion

strtolower() corrupts all UTF-8 share names that have a byte in the C0
(À ISO8859-1) to DE (Þ ISO8859-1) range, since the non-ASCII part of
ISO8859-1 is incompatible with UTF-8. Prevent this by checking that a
byte is in the ASCII range with isascii(), before the conversion to
lowercase with tolower(). Properly handle case-insensitivity of UTF-8
share names by casefolding them, but fallback to ASCII lowercase
conversion on failure or if CONFIG_UNICODE is not set. Refactor to move
the share name casefolding immediately after the share name extraction.
Also, make the associated constness corrections.

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.c
fs/ksmbd/connection.h
fs/ksmbd/mgmt/share_config.c
fs/ksmbd/mgmt/share_config.h
fs/ksmbd/mgmt/tree_connect.c
fs/ksmbd/mgmt/tree_connect.h
fs/ksmbd/misc.c
fs/ksmbd/misc.h
fs/ksmbd/smb2pdu.c
fs/ksmbd/unicode.h