Fix string lacking null termination in IsFileExtension

When file extension is longer or equal length compared to buffer holding lowercased string, strncpy does not null terminate the string.
Increased buffer size by 1 to ensure it will always be null-terminated, so that following strcmp does not read out of buffer bounds.
This commit is contained in:
HarriP 2022-08-13 18:05:32 +03:00
parent 56072a631d
commit b0e0f2ca80

View File

@ -2842,7 +2842,7 @@ bool IsFileExtension(const char *fileName, const char *ext)
int extCount = 0; int extCount = 0;
const char **checkExts = TextSplit(ext, ';', &extCount); // WARNING: Module required: rtext const char **checkExts = TextSplit(ext, ';', &extCount); // WARNING: Module required: rtext
char fileExtLower[MAX_FILE_EXTENSION_SIZE] = { 0 }; char fileExtLower[MAX_FILE_EXTENSION_SIZE + 1] = { 0 };
strncpy(fileExtLower, TextToLower(fileExt),MAX_FILE_EXTENSION_SIZE); // WARNING: Module required: rtext strncpy(fileExtLower, TextToLower(fileExt),MAX_FILE_EXTENSION_SIZE); // WARNING: Module required: rtext
for (int i = 0; i < extCount; i++) for (int i = 0; i < extCount; i++)