linux-hardened/fs/nls
OGAWA Hirofumi 67638e4043 fat/nls: Fix handling of utf8 invalid char
With utf8 option, vfat allowed the duplicated filenames.

Normal nls returns -EINVAL for invalid char. But utf8s_to_utf16s()
skipped the invalid char historically.

So, this changes the utf8s_to_utf16s() directly to return -EINVAL for
invalid char, because vfat is only user of it.

mkdir /mnt/fatfs
FILENAME=`echo -ne "invalidutf8char_\\0341_endofchar"`
echo "Using filename: $FILENAME"
dd if=/dev/zero of=fatfs bs=512 count=128
mkdosfs -F 32 fatfs
mount -o loop,utf8 fatfs /mnt/fatfs
touch "/mnt/fatfs/$FILENAME"
umount /mnt/fatfs
mount -o loop,utf8 fatfs /mnt/fatfs
touch "/mnt/fatfs/$FILENAME"
ls -l /mnt/fatfs
umount /mnt/fatfs

----  And the output is:

Using filename: invalidutf8char_\0341_endofchar
128+0 records in
128+0 records out
65536 bytes (66 kB) copied, 0.000388118 s, 169 MB/s
mkdosfs 2.11 (12 Mar 2005)
total 0
-rwxr-xr-x 1 root root 0 Jun 28 19:46 invalidutf8char__endofchar
-rwxr-xr-x 1 root root 0 Jun 28 19:46 invalidutf8char__endofchar

Tested-by: Marton Balint <cus@fazekas.hu>
Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
2009-08-01 21:35:21 +09:00
..
Kconfig menuconfig: transform NLS and DLM menus 2007-10-17 08:43:00 -07:00
Makefile
nls_ascii.c
nls_base.c fat/nls: Fix handling of utf8 invalid char 2009-08-01 21:35:21 +09:00
nls_cp437.c
nls_cp737.c
nls_cp775.c
nls_cp850.c
nls_cp852.c
nls_cp855.c
nls_cp857.c
nls_cp860.c
nls_cp861.c
nls_cp862.c
nls_cp863.c
nls_cp864.c
nls_cp865.c
nls_cp866.c
nls_cp869.c
nls_cp874.c
nls_cp932.c
nls_cp936.c
nls_cp949.c
nls_cp950.c
nls_cp1250.c
nls_cp1251.c
nls_cp1255.c
nls_euc-jp.c
nls_iso8859-1.c
nls_iso8859-2.c
nls_iso8859-3.c
nls_iso8859-4.c
nls_iso8859-5.c
nls_iso8859-6.c
nls_iso8859-7.c
nls_iso8859-9.c
nls_iso8859-13.c
nls_iso8859-14.c
nls_iso8859-15.c
nls_koi8-r.c
nls_koi8-ru.c
nls_koi8-u.c
nls_utf8.c NLS: update handling of Unicode 2009-06-15 21:44:43 -07:00