Platform::isSubDirectory problem on linux
by James Urquhart · in Torque Game Engine · 11/13/2004 (4:00 am) · 5 replies
There seems to be a problem with the Platform::isSubDirectory function in X86UNIXFileio.cc.
The following block of code is incorrect :
If "stat" fails, it will take the whole directory walker loop with it.
Since stat is called for each file found in the directory, one error in a file entry (such as incorrect access rights, too many symbolic links, etc) will result in the code not being able to find all the entries in a directory.
Since this function is used in ResManager in setModPaths to determine if a mod is really in a .zip, a mod could fail to load, This happened in my case, as a broken symbolic link was put through stat() before the common folder, so torque thought it was a .zip, and so common failed to load.
To solve this problem, one only need to do "continue;" instead of "return false;", aka :
How to reproduce
Create a symbolic link in your torque directory (where your engine executable is located) that points to a non-existent file, e.g. :
You will need to ensure somehow that your file appears before one of your mod folders in the directory's list to encounter the bug.
The following block of code is incorrect :
if (stat(dirBuf, &fStat) < 0)
return false;If "stat" fails, it will take the whole directory walker loop with it.
Since stat is called for each file found in the directory, one error in a file entry (such as incorrect access rights, too many symbolic links, etc) will result in the code not being able to find all the entries in a directory.
Since this function is used in ResManager in setModPaths to determine if a mod is really in a .zip, a mod could fail to load, This happened in my case, as a broken symbolic link was put through stat() before the common folder, so torque thought it was a .zip, and so common failed to load.
To solve this problem, one only need to do "continue;" instead of "return false;", aka :
if (stat(dirBuf, &fStat) < 0)
continue;How to reproduce
Create a symbolic link in your torque directory (where your engine executable is located) that points to a non-existent file, e.g. :
ln -s /non/existant/file myfile.txt
You will need to ensure somehow that your file appears before one of your mod folders in the directory's list to encounter the bug.
About the author
Torque Owner Benoit Touchette
--- platformX86UNIX/x86UNIXFileio.cc 2004-11-13 23:41:03.397330064 -0500 +++ platformLinux/x86UNIXFileio.cc 2004-11-13 23:37:43.133774752 -0500 @@ -941,7 +941,11 @@ dSprintf(dirBuf, sizeof(dirBuf), "%s/%s", pParent, fEntry->d_name); if (stat(dirBuf, &fStat) < 0) +#if defined(TORQUE_OS_LINUX) + continue; +#else return false; +#endif