Fix filesearch trying to open file symlinks as directory

This commit is contained in:
indev committed 2023-11-20 16:10:02 +03:00
1 parent bb9f7c8196
commit d06f923066
2 files changed
+8 -2

No files matched your search

+7 -1
View File
@@ -401,8 +401,14 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want
if (lstat(searchpath,&fsstat) == 0 && S_ISDIR(fsstat.st_mode))
dent->d_type = DT_DIR;
else if (lstat(searchpath,&fsstat) == 0 && S_ISLNK(fsstat.st_mode))
dent->d_type = DT_LNK;
dent->d_type = DT_LNK;
// Symlinks aren't always directory symlinks. Dunno if this would resolve recursive
// symlinks, but i think stat already does that
if (dent->d_type == DT_LNK && stat(searchpath,&fsstat) == 0 && !S_ISDIR(fsstat.st_mode))
{
dent->d_type = DT_UNKNOWN;
}
// Linux and FreeBSD has a special field for file type on dirent, so use that to speed up lookups.
// FIXME: should we also follow symlinks?
+1 -1
View File
@@ -202,7 +202,7 @@ FILE *W_OpenWadFile(const char **filename, boolean useerrors)
// If findfile finds the file, the full path will be returned
// in filenamebuf == *filename.
if (findfile(filenamebuf, NULL, true))
if (findfile(filenamebuf, NULL, true) == FS_FOUND)
{
if ((handle = fopen_utf8(*filename, "rb")) == NULL)
{