From bea8cd68840d1f1c3aa169fa9466616344c98660 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 17 Oct 2018 15:55:10 +0100 Subject: [PATCH] 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 --- src/osgDB/FileUtils.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/osgDB/FileUtils.cpp b/src/osgDB/FileUtils.cpp index f76ec4f80..c0c8cec88 100644 --- a/src/osgDB/FileUtils.cpp +++ b/src/osgDB/FileUtils.cpp @@ -342,6 +342,11 @@ std::string osgDB::findFileInPath(const std::string& filename, const FilePathLis OSG_DEBUG << "itr='" <<*itr<< "'\n"; 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); OSG_DEBUG << "FindFileInPath() : trying " << path << " ...\n";