From ed6115361006240e3c7b02295599e4534cc55a13 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 19 Oct 2013 08:57:20 +0200 Subject: Update internal Boost subset to 1.54.0 --- cutl/details/boost/regex/src/fileiter.cxx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'cutl/details/boost/regex/src/fileiter.cxx') diff --git a/cutl/details/boost/regex/src/fileiter.cxx b/cutl/details/boost/regex/src/fileiter.cxx index 0a669a8..9a99222 100644 --- a/cutl/details/boost/regex/src/fileiter.cxx +++ b/cutl/details/boost/regex/src/fileiter.cxx @@ -19,6 +19,7 @@ #define BOOST_REGEX_SOURCE +#include #include #include #include @@ -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; -- cgit v1.1