From f317c186bcb440e4b460cfb2ca61b9b1ab7010ce Mon Sep 17 00:00:00 2001 From: MegAmi Date: Fri, 29 Dec 2023 12:26:02 -0600 Subject: [PATCH] Fix fcaseopen.c buffer overflow Should fix #232 --- RSDKv3/fcaseopen.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/RSDKv3/fcaseopen.c b/RSDKv3/fcaseopen.c index 23fcaa69..0bdefbd8 100644 --- a/RSDKv3/fcaseopen.c +++ b/RSDKv3/fcaseopen.c @@ -30,7 +30,7 @@ THE SOFTWARE. #include #include -// r must have strlen(path) + 2 bytes +// r must have strlen(path) + 3 bytes static int casepath(char const *path, char *r) { size_t l = strlen(path); @@ -101,7 +101,7 @@ FILE *fcaseopen(char const *path, char const *mode) FILE *f = fopen(path, mode); #if !defined(_WIN32) if (!f) { - char *r = (char *)alloca(strlen(path) + 2); + char *r = (char *)alloca(strlen(path) + 3); if (casepath(path, r)) { f = fopen(r, mode); } @@ -113,7 +113,7 @@ FILE *fcaseopen(char const *path, char const *mode) void casechdir(char const *path) { #if !defined(_WIN32) - char *r = (char *)alloca(strlen(path) + 2); + char *r = (char *)alloca(strlen(path) + 3); if (casepath(path, r)) { chdir(r); }