Skip to content
This repository was archived by the owner on Nov 11, 2024. It is now read-only.

Commit d59c7c8

Browse files
committed
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.
1 parent cf268b3 commit d59c7c8

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

source/directory.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ static int _FAT_directory_lfnLength (const char* name) {
9898
}
9999
// Make sure the name doesn't contain any control codes or codes not representable in UCS-2
100100
for (i = 0; i < nameLength; i++) {
101-
if (name[i] < 0x20 || name[i] >= ABOVE_UCS_RANGE) {
101+
unsigned char ch = (unsigned char) name[i];
102+
if (ch < 0x20 || ch >= ABOVE_UCS_RANGE) {
102103
return -1;
103104
}
104105
}

0 commit comments

Comments
 (0)