Added check under Windows for a concatinated path that exceeds the MAX_PATH so that it isn't used for file IO operations that could lead to undefined behavior

https://github.com/openscenegraph/OpenSceneGraph/issues/634
This commit is contained in:
Robert Osfield 2018-10-17 15:55:10 +01:00
parent 8af46a6e98
commit bf5a88870f

View File

@ -342,6 +342,11 @@ std::string osgDB::findFileInPath(const std::string& filename, const FilePathLis
OSG_DEBUG << "itr='" <<*itr<< "'\n"; OSG_DEBUG << "itr='" <<*itr<< "'\n";
std::string path = itr->empty() ? filename : concatPaths(*itr, filename); std::string path = itr->empty() ? filename : concatPaths(*itr, filename);
#ifdef WIN32
// if combined file path exceeds MAX_PATH then ignore as it's not a legal path otherwise subsequent IO calls with this path may result in undefined behavior
if (path.length()>MAX_PATH) continue;
#endif
path = getRealPath(path); path = getRealPath(path);
OSG_DEBUG << "FindFileInPath() : trying " << path << " ...\n"; OSG_DEBUG << "FindFileInPath() : trying " << path << " ...\n";