From 8630f072e9b544cb9b58291fe3a60daccc899d46 Mon Sep 17 00:00:00 2001 From: Rani Hod Date: Mon, 31 Jul 2006 22:59:45 +0000 Subject: Applied FS# 5736 by Alexander Levin. Fixed fat buffer overflow with LFNs longer than 255 bytes. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10389 a1c6a512-1295-4272-9138-f99709370657 --- firmware/export/fat.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'firmware/export/fat.h') diff --git a/firmware/export/fat.h b/firmware/export/fat.h index c56d8f85f6..4cdc479844 100644 --- a/firmware/export/fat.h +++ b/firmware/export/fat.h @@ -25,9 +25,17 @@ #define SECTOR_SIZE 512 +/* Number of bytes reserved for a file name (including the trailing \0). + Since names are stored in the entry as UTF-8, we won't be able to + store all names allowed by FAT. In FAT, a name can have max 255 + characters (not bytes!). Since the UTF-8 encoding of a char may take + up to 4 bytes, there will be names that we won't be able to store + completely. For such names, the short DOS name is used. */ +#define FAT_FILENAME_BYTES 256 + struct fat_direntry { - unsigned char name[256]; /* Name plus \0 */ + unsigned char name[FAT_FILENAME_BYTES]; /* UTF-8 encoded name plus \0 */ unsigned short attr; /* Attributes */ unsigned char crttimetenth; /* Millisecond creation time stamp (0-199) */ -- cgit v1.2.3