mirror of
https://github.com/wiiu-env/libfat.git
synced 2024-11-21 17:39:17 +01:00
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:
parent
cf268b3ecd
commit
d59c7c8b35
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user