1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 19:13:07 +01:00

Fix #9267: Only check if a file is a directory before opening it (#9269)

This commit is contained in:
ζeh Matt
2019-05-16 09:05:09 +02:00
committed by Ted John
parent 1978372679
commit f7bd6d516a

View File

@@ -76,9 +76,16 @@ public:
free(pathW);
free(modeW);
#else
struct stat fileStat;
// Only allow regular files to be opened as its possible to open directories.
if (stat(path, &fileStat) == 0 && S_ISREG(fileStat.st_mode))
if (fileMode == FILE_MODE_OPEN)
{
struct stat fileStat;
// Only allow regular files to be opened as its possible to open directories.
if (stat(path, &fileStat) == 0 && S_ISREG(fileStat.st_mode))
{
_file = fopen(path, mode);
}
}
else
{
_file = fopen(path, mode);
}