summaryrefslogtreecommitdiff
path: root/fs/ksmbd/unicode.h
diff options
context:
space:
mode:
authorAtte Heikkilä <atteh.mailbox@gmail.com>2022-09-15 16:49:11 +0300
committerSteve French <stfrench@microsoft.com>2022-10-05 09:15:37 +0300
commit16b5f54e30c1ddec36bdf946a299b3254aace477 (patch)
treedf57c1e9c146006b13183ba9e8a117accdfc02c7 /fs/ksmbd/unicode.h
parent276a3f7cf1d9bae125d8cdc345f67ec52751d704 (diff)
downloadlinux-16b5f54e30c1ddec36bdf946a299b3254aace477.tar.xz
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>
Diffstat (limited to 'fs/ksmbd/unicode.h')
-rw-r--r--fs/ksmbd/unicode.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/ksmbd/unicode.h b/fs/ksmbd/unicode.h
index 5593024230ae..076f6034a789 100644
--- a/fs/ksmbd/unicode.h
+++ b/fs/ksmbd/unicode.h
@@ -24,6 +24,7 @@
#include <asm/byteorder.h>
#include <linux/types.h>
#include <linux/nls.h>
+#include <linux/unicode.h>
#define UNIUPR_NOLOWER /* Example to not expand lower case tables */
@@ -69,7 +70,7 @@ char *smb_strndup_from_utf16(const char *src, const int maxlen,
const struct nls_table *codepage);
int smbConvertToUTF16(__le16 *target, const char *source, int srclen,
const struct nls_table *cp, int mapchars);
-char *ksmbd_extract_sharename(char *treename);
+char *ksmbd_extract_sharename(struct unicode_map *um, const char *treename);
#endif
/*