diff options
Diffstat (limited to '3rdParty/Boost/src/libs/regex/src/fileiter.cpp')
-rw-r--r-- | 3rdParty/Boost/src/libs/regex/src/fileiter.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/3rdParty/Boost/src/libs/regex/src/fileiter.cpp b/3rdParty/Boost/src/libs/regex/src/fileiter.cpp index ff1d111..780a12f 100644 --- a/3rdParty/Boost/src/libs/regex/src/fileiter.cpp +++ b/3rdParty/Boost/src/libs/regex/src/fileiter.cpp @@ -19,6 +19,7 @@ #define BOOST_REGEX_SOURCE +#include <boost/config.hpp> #include <climits> #include <stdexcept> #include <string> @@ -847,10 +848,16 @@ bool iswild(const char* mask, const char* name) unsigned _fi_attributes(const char* root, const char* name) { char buf[MAX_PATH]; + // verify that we can not overflow: + if(std::strlen(root) + std::strlen(_fi_sep) + std::strlen(name) >= MAX_PATH) + return 0; + int r; if( ( (root[0] == *_fi_sep) || (root[0] == *_fi_sep_alt) ) && (root[1] == '\0') ) - (std::sprintf)(buf, "%s%s", root, name); + r = (std::sprintf)(buf, "%s%s", root, name); else - (std::sprintf)(buf, "%s%s%s", root, _fi_sep, name); + r = (std::sprintf)(buf, "%s%s%s", root, _fi_sep, name); + if(r < 0) + return 0; // sprintf failed DIR* d = opendir(buf); if(d) { @@ -870,6 +877,7 @@ _fi_find_handle _fi_FindFirstFile(const char* lpFileName, _fi_find_data* lpFindF { if(_fi_FindNextFile(dat, lpFindFileData)) return dat; + closedir(h); } delete dat; return 0; |