From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
To: Keith Mok <ek9852@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] vfat: bug fix for vfat cannot handle filename with 255 asian characters when mounted with utf8
Date: Fri, 15 Feb 2008 17:41:23 +0900 [thread overview]
Message-ID: <87ejbea9xo.fsf@duaron.myhome.or.jp> (raw)
In-Reply-To: <47B3213E.1020407@gmail.com> (Keith Mok's message of "Thu, 14 Feb 2008 00:56:30 +0800")
Keith Mok <ek9852@gmail.com> writes:
> This patch fix the problem that the buffer allocated for convert of
> unicode to utf8 in fat/dir.c is too small.
> And cannot handle filename with 255 asian characters when mounted with
> utf8 options.
>
> Also it fix the filename length limitation checking in vfat/namei.c that
> the filename length should be checked against the number of converted
> unicode characters.
> Not the length before NLS/UTF8 converted.
>
> Any comments ?
Looks good. But it seems to have some problems.
And we will need cleanup the original code related this
patch. Unfortunately, it's really dirty although unrelated to this
patch.
> --- linux-source-2.6.22/fs/vfat/namei.c.orig 2007-07-09 07:32:17.000000000 +0800
> +++ linux-source-2.6.22/fs/vfat/namei.c 2008-02-13 22:56:14.000000000 +0800
> @@ -176,15 +176,8 @@ static inline int vfat_is_used_badchars(
> for (i = 0; i < len; i++)
> if (vfat_bad_char(s[i]))
> return -EINVAL;
> - return 0;
> -}
> -
> -static int vfat_valid_longname(const unsigned char *name, unsigned int len)
> -{
> - if (name[len - 1] == ' ')
> + if(s[i-1] == 0x0020) /* last character cannot be space */
Please use the following style. (See Documentation/CodingStyle)
if (s[i - 1] == 0x0020)
> @@ -489,7 +482,7 @@ xlate_to_uni(const unsigned char *name,
> } else {
> if (nls) {
> for (i = 0, ip = name, op = outname, *outlen = 0;
> - i < len && *outlen <= 260;
> + i < len && *outlen <= 255;
> *outlen += 1)
> {
> if (escape && (*ip == ':')) {
Don't we also need to fix the "utf8" option case?
> --- linux-source-2.6.22/fs/fat/dir.c.orig 2007-07-09 07:32:17.000000000 +0800
> +++ linux-source-2.6.22/fs/fat/dir.c 2008-02-14 00:42:52.000000000 +0800
> @@ -124,7 +124,7 @@ static inline int fat_get_entry(struct i
> * but ignore that right now.
> * Ahem... Stack smashing in ring 0 isn't fun. Fixed.
> */
> -static int uni16_to_x8(unsigned char *ascii, wchar_t *uni, int uni_xlate,
> +static int uni16_to_x8(unsigned char *ascii, wchar_t *uni, int len, int uni_xlate,
> struct nls_table *nls)
> {
> wchar_t *ip, ec;
> @@ -135,10 +135,13 @@ static int uni16_to_x8(unsigned char *as
> ip = uni;
> op = ascii;
>
> - while (*ip) {
> + BUG_ON(len <= NLS_MAX_CHARSET_SIZE);
Do we need this check?
> + while (*ip && (len-NLS_MAX_CHARSET_SIZE)>0) {
coding style
--
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
next prev parent reply other threads:[~2008-02-15 8:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-13 16:56 Keith Mok
2008-02-15 8:41 ` OGAWA Hirofumi [this message]
2008-02-15 10:40 ` Keith Mok
2008-02-15 10:52 ` OGAWA Hirofumi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ejbea9xo.fsf@duaron.myhome.or.jp \
--to=hirofumi@mail.parknet.co.jp \
--cc=ek9852@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®