lkml.org 
[lkml]   [2003]   [Dec]   [6]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
DateSat, 6 Dec 2003 09:55:39 +0100
FromMichal Rokos <>
Subject[PATCH 2.6.0-test11] VFAT fix for UTF-8 and trailing dots
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
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:59    [from the cache]
©2003-2008