Skip to content

Commit

Permalink
Fix fcaseopen.c buffer overflow
Browse files Browse the repository at this point in the history
Should fix #232
  • Loading branch information
MegAmi24 authored Dec 29, 2023
1 parent 9832a50 commit f317c18
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions RSDKv3/fcaseopen.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ THE SOFTWARE.
#include <errno.h>
#include <unistd.h>

// 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);
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down

0 comments on commit f317c18

Please sign in to comment.