From b0e0f2ca8054b3a2dd17e84daa1fe77c73a1f441 Mon Sep 17 00:00:00 2001 From: HarriP Date: Sat, 13 Aug 2022 18:05:32 +0300 Subject: [PATCH] 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. --- src/rcore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rcore.c b/src/rcore.c index dbdec801d..7acedf6c2 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -2842,7 +2842,7 @@ bool IsFileExtension(const char *fileName, const char *ext) int extCount = 0; 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 for (int i = 0; i < extCount; i++)