From bf5a88870f55731d341d56d8d05a66c1fbe0d1a1 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";