More correctly handle the case where plain char is signed

In _FAT_directory_lfnLength, the check 'ch < 0x20' incorrectly catches
any extended UTF-8 bytes if the plain 'char' type is signed:

  0x80 < 0x20 ... 0xEF < 0x20

are interpreted as (negative value < 32). The check for 0xF0 and above
also fails to work properly due to 0xF0 being negative as well.
This commit is contained in:
Nebuleon Fumika 2016-06-19 19:48:48 +00:00
parent cf268b3ecd
commit d59c7c8b35

View File

@ -98,7 +98,8 @@ static int _FAT_directory_lfnLength (const char* name) {
}
// Make sure the name doesn't contain any control codes or codes not representable in UCS-2
for (i = 0; i < nameLength; i++) {
if (name[i] < 0x20 || name[i] >= ABOVE_UCS_RANGE) {
unsigned char ch = (unsigned char) name[i];
if (ch < 0x20 || ch >= ABOVE_UCS_RANGE) {
return -1;
}
}