summaryrefslogtreecommitdiffhomepage
path: root/src/rcore.c
diff options
context:
space:
mode:
authorHarriP <[email protected]>2022-08-13 18:36:29 +0300
committerGitHub <[email protected]>2022-08-13 17:36:29 +0200
commite0b487c6411811af7e9a9ecc24e53a0367676985 (patch)
tree9e6cf965dcfa825b26cb39742ff3d07d4ad8d618 /src/rcore.c
parent56072a631dbcde21c4b65917c1ce97262d064a5a (diff)
downloadraylib-e0b487c6411811af7e9a9ecc24e53a0367676985.tar.gz
raylib-e0b487c6411811af7e9a9ecc24e53a0367676985.zip
Fix string lacking null termination in IsFileExtension (#2637)
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.
Diffstat (limited to 'src/rcore.c')
-rw-r--r--src/rcore.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/rcore.c b/src/rcore.c
index dbdec801..7acedf6c 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++)