Commit de6ca58c authored by Liyang Hu's avatar Liyang Hu Committed by Linus Torvalds

[PATCH] Bug in NLS UTF-8 code

I've recently (actually, last month, but I had been a bit too busy
since then) come across a wee problem, in what I originally thought
was the VFAT code -- having `utf8' as one of the options, creating
UTF-8 file names on a VFAT partition mysteriously gains a couple of
(random) characters just after the UTF-8 escaped character: eg.
touch "fooCbar" where C is an UTF-8 escape sequence ends up creating
a file named "fooCRbar". (R being some random character.)

I eventually tracked it down to one line in fs/nls/nls_base.c -- the
UCS-2 (wchar_t) string pointer was being incremented too fast. After
consulting Ogawa Hirofumi-san on the subject, he mentioned that
include/linux/nls.h also needs to be changed for proper UTF-8
support in the NLS code.
parent c544f64e
/*
* linux/fs/nls.c
* linux/fs/nls_base.c
*
* Native language support--charsets and unicode translations.
* By Gordon Chaffee 1996, 1997
......@@ -93,7 +93,7 @@ utf8_mbstowcs(wchar_t *pwcs, const __u8 *s, int n)
ip++;
n--;
} else {
op += size;
op++;
ip += size;
n -= size;
}
......
......@@ -18,7 +18,7 @@ struct nls_table {
};
/* this value hold the maximum octet of charset */
#define NLS_MAX_CHARSET_SIZE 3
#define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
/* nls.c */
extern int register_nls(struct nls_table *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment