linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2.6.0-test11] VFAT fix for UTF-8 and trailing dots
@ 2003-12-06  8:55 Michal Rokos
  2003-12-06 15:52 ` OGAWA Hirofumi
  0 siblings, 1 reply; 4+ messages in thread
From: Michal Rokos @ 2003-12-06  8:55 UTC (permalink / raw)
  To: hirofumi; +Cc: linux-kernel

Hello all,

there is one problem with vfat when UTF-8 option is on...

The problem is: even if vfat_striptail_len() counts len of name without
trailing dots and sets len to the correct value, utf8_mbstowcs() doesn't
care about len and takes whole name.
So dirs and files with dots can be created on vfat fs and that will
cause some problems as you know :)

This patch just shortens outlen to the correct value - nothing else.

Compiled, tested.

Please concider the inclusion.

Thank you.

	Michal

--- linux-2.6.0-test11/fs/vfat/namei.c.old	2003-11-26 21:44:34.000000000 +0100
+++ linux-2.6.0-test11/fs/vfat/namei.c	2003-12-06 09:34:44.000000000 +0100
@@ -573,13 +573,18 @@ xlate_to_uni(const unsigned char *name, 
 	int charlen;
 
 	if (utf8) {
+		int name_len = strlen(name);
+
 		*outlen = utf8_mbstowcs((wchar_t *)outname, name, PAGE_SIZE);
-		if (name[len-1] == '.')
-			*outlen-=2;
+
+		/* 
+		 * We stripped '.'s before and set len appropriately,
+		 * but utf8_mbstowcs doesn't care about len
+		 */
+		*outlen -= (name_len-len);
+
 		op = &outname[*outlen * sizeof(wchar_t)];
 	} else {
-		if (name[len-1] == '.') 
-			len--;
 		if (nls) {
 			for (i = 0, ip = name, op = outname, *outlen = 0;
 			     i < len && *outlen <= 260; *outlen += 1)

-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Michal Rokos                         Czech Technical University, Prague
e-mail: m.rokos@sh.cvut.cz    icq: 36118339     jabber: majkl@jabber.cz
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2.6.0-test11] VFAT fix for UTF-8 and trailing dots
  2003-12-06  8:55 [PATCH 2.6.0-test11] VFAT fix for UTF-8 and trailing dots Michal Rokos
@ 2003-12-06 15:52 ` OGAWA Hirofumi
  2003-12-06 19:29   ` Michal Rokos
  0 siblings, 1 reply; 4+ messages in thread
From: OGAWA Hirofumi @ 2003-12-06 15:52 UTC (permalink / raw)
  To: Michal Rokos; +Cc: linux-kernel

Michal Rokos <m.rokos@sh.cvut.cz> writes:

> The problem is: even if vfat_striptail_len() counts len of name without
> trailing dots and sets len to the correct value, utf8_mbstowcs() doesn't
> care about len and takes whole name.
> So dirs and files with dots can be created on vfat fs and that will
> cause some problems as you know :)

[...]

>  	if (utf8) {
> +		int name_len = strlen(name);
> +
>  		*outlen = utf8_mbstowcs((wchar_t *)outname, name, PAGE_SIZE);
> -		if (name[len-1] == '.')
> -			*outlen-=2;
> +
> +		/* 
> +		 * We stripped '.'s before and set len appropriately,
> +		 * but utf8_mbstowcs doesn't care about len
> +		 */
> +		*outlen -= (name_len-len);
> +
>  		op = &outname[*outlen * sizeof(wchar_t)];

Indeed. However, this looks not right fix. I think utf8_mbstowcs()
should take the length of both outname and name, so we should fix the
utf8_mbstowcs().

For example, utf8_mbstowcs(outbuf, outlen, inbuf, inlen);

Thanks.
-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2.6.0-test11] VFAT fix for UTF-8 and trailing dots
  2003-12-06 15:52 ` OGAWA Hirofumi
@ 2003-12-06 19:29   ` Michal Rokos
  2003-12-06 21:02     ` OGAWA Hirofumi
  0 siblings, 1 reply; 4+ messages in thread
From: Michal Rokos @ 2003-12-06 19:29 UTC (permalink / raw)
  To: OGAWA Hirofumi; +Cc: linux-kernel

Hi,

On Sun, Dec 07, 2003 at 12:52:07AM +0900, OGAWA Hirofumi wrote:
> Michal Rokos <m.rokos@sh.cvut.cz> writes:
> 
> > The problem is: even if vfat_striptail_len() counts len of name without
> > trailing dots and sets len to the correct value, utf8_mbstowcs() doesn't
> > care about len and takes whole name.
> > So dirs and files with dots can be created on vfat fs and that will
> > cause some problems as you know :)
> 
> [...]
> 
> >  	if (utf8) {
> > +		int name_len = strlen(name);
> > +
> >  		*outlen = utf8_mbstowcs((wchar_t *)outname, name, PAGE_SIZE);
> > -		if (name[len-1] == '.')
> > -			*outlen-=2;
> > +
> > +		/* 
> > +		 * We stripped '.'s before and set len appropriately,
> > +		 * but utf8_mbstowcs doesn't care about len
> > +		 */
> > +		*outlen -= (name_len-len);
> > +
> >  		op = &outname[*outlen * sizeof(wchar_t)];
> 
> Indeed. However, this looks not right fix. I think utf8_mbstowcs()
> should take the length of both outname and name, so we should fix the
> utf8_mbstowcs().

I don't know... Functions in nls_base.c have specification the same as
those from userspace (defined by ISO/ANSI C or UNIX98).

Probably we should. This was meant as minimal patch.

In case you'll be modifiing nls_base.c, please, decide whether this
shouldn't be in...


--- linux-2.6.0-test11/fs/nls/nls_base.c.old	2003-11-26 21:44:31.000000000 +0100
+++ linux-2.6.0-test11/fs/nls/nls_base.c	2003-12-06 20:09:01.000000000 +0100
@@ -99,6 +99,7 @@ utf8_mbstowcs(wchar_t *pwcs, const __u8 
 			}
 		} else {
 			*op++ = *ip++;
+			n--;
 		}
 	}
 	return (op - pwcs);
> 
> For example, utf8_mbstowcs(outbuf, outlen, inbuf, inlen);
> 

I'd would propose uft8_mbsntowcs(outbuf, outlen, inbuf, inlen);

BR

	Michal

-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Michal Rokos                         Czech Technical University, Prague
e-mail: m.rokos@sh.cvut.cz    icq: 36118339     jabber: majkl@jabber.cz
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2.6.0-test11] VFAT fix for UTF-8 and trailing dots
  2003-12-06 19:29   ` Michal Rokos
@ 2003-12-06 21:02     ` OGAWA Hirofumi
  0 siblings, 0 replies; 4+ messages in thread
From: OGAWA Hirofumi @ 2003-12-06 21:02 UTC (permalink / raw)
  To: Michal Rokos; +Cc: linux-kernel

Michal Rokos <m.rokos@sh.cvut.cz> writes:

> I don't know... Functions in nls_base.c have specification the same as
> those from userspace (defined by ISO/ANSI C or UNIX98).
> 
> Probably we should. This was meant as minimal patch.
> 
> In case you'll be modifiing nls_base.c, please, decide whether this
> shouldn't be in...
> 
> 
> --- linux-2.6.0-test11/fs/nls/nls_base.c.old	2003-11-26 21:44:31.000000000 +0100
> +++ linux-2.6.0-test11/fs/nls/nls_base.c	2003-12-06 20:09:01.000000000 +0100
> @@ -99,6 +99,7 @@ utf8_mbstowcs(wchar_t *pwcs, const __u8 
>  			}
>  		} else {
>  			*op++ = *ip++;
> +			n--;
>  		}
>  	}
>  	return (op - pwcs);
> > 
> > For example, utf8_mbstowcs(outbuf, outlen, inbuf, inlen);
> > 
> 
> I'd would propose uft8_mbsntowcs(outbuf, outlen, inbuf, inlen);

Whoops, sorry. You are right.

But I really like the interface like iconv() than this. And current
nls interfaces also...

Anyway, I think your patches fix some bugs right now.
I'll submit the your both patches.

Thanks.
-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-12-06 21:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-06  8:55 [PATCH 2.6.0-test11] VFAT fix for UTF-8 and trailing dots Michal Rokos
2003-12-06 15:52 ` OGAWA Hirofumi
2003-12-06 19:29   ` Michal Rokos
2003-12-06 21:02     ` OGAWA Hirofumi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).