Skip to content

Commit

Permalink
Fix fcaseopen.c buffer overflow
Browse files Browse the repository at this point in the history
Should fix #426
  • Loading branch information
MegAmi24 authored Dec 29, 2023
1 parent 72de771 commit 64c4b17
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions RSDKv4/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 @@ -109,7 +109,7 @@ FILE *fcaseopen(char const *path, char const *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 @@ -122,7 +122,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 64c4b17

Please sign in to comment.