Commit e8f2950f authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] FAT: Fix the tailing dots on the utf8 path (2/10)

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.
parent f17963ee
...@@ -99,6 +99,7 @@ utf8_mbstowcs(wchar_t *pwcs, const __u8 *s, int n) ...@@ -99,6 +99,7 @@ utf8_mbstowcs(wchar_t *pwcs, const __u8 *s, int n)
} }
} else { } else {
*op++ = *ip++; *op++ = *ip++;
n--;
} }
} }
return (op - pwcs); return (op - pwcs);
......
...@@ -573,13 +573,18 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname, ...@@ -573,13 +573,18 @@ xlate_to_uni(const unsigned char *name, int len, unsigned char *outname,
int charlen; int charlen;
if (utf8) { if (utf8) {
int name_len = strlen(name);
*outlen = utf8_mbstowcs((wchar_t *)outname, name, PAGE_SIZE); *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)]; op = &outname[*outlen * sizeof(wchar_t)];
} else { } else {
if (name[len-1] == '.')
len--;
if (nls) { if (nls) {
for (i = 0, ip = name, op = outname, *outlen = 0; for (i = 0, ip = name, op = outname, *outlen = 0;
i < len && *outlen <= 260; *outlen += 1) i < len && *outlen <= 260; *outlen += 1)
......
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