]> git.hungrycats.org Git - linux/commitdiff
[PATCH] FAT: Fix the tailing dots on the utf8 path (2/10)
authorAndrew Morton <akpm@osdl.org>
Tue, 30 Dec 2003 07:45:07 +0000 (23:45 -0800)
committerLinus Torvalds <torvalds@home.osdl.org>
Tue, 30 Dec 2003 07:45:07 +0000 (23:45 -0800)
From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
      Michal Rokos <m.rokos@sh.cvut.cz>

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.

fs/nls/nls_base.c
fs/vfat/namei.c

index 0372a32e0421d2bff230703868a8945c0bce9983..07b8bea20dc2416b719140bff2fa3f1b4870c2dc 100644 (file)
@@ -99,6 +99,7 @@ utf8_mbstowcs(wchar_t *pwcs, const __u8 *s, int n)
                        }
                } else {
                        *op++ = *ip++;
+                       n--;
                }
        }
        return (op - pwcs);
index d610af53967e282f88f7f41e3c4d2ebe45d9524d..dd928874c2974686fe371e0c776f07afdbb15a9f 100644 (file)
@@ -573,13 +573,18 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname,
        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)