mail[Wesnoth-commits] r33316 - /trunk/src/filesystem.cpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by guillaume . melquiond on March 03, 2009 - 18:44:
Author: silene
Date: Tue Mar  3 18:44:38 2009
New Revision: 33316

URL: http://svn.gna.org/viewcvs/wesnoth?rev=33316&view=rev
Log:
Prevented '..' in binary types and paths.

Modified:
    trunk/src/filesystem.cpp

Modified: trunk/src/filesystem.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/filesystem.cpp?rev=33316&r1=33315&r2=33316&view=diff
==============================================================================
--- trunk/src/filesystem.cpp (original)
+++ trunk/src/filesystem.cpp Tue Mar  3 18:44:38 2009
@@ -920,9 +920,13 @@
        cleanup();
        init_binary_paths();
 
-       const config::child_list& items = cfg.get_children("binary_path");
-       for(config::child_list::const_iterator i = items.begin(); i != 
items.end(); ++i) {
-               std::string path = (**i)["path"].str();
+       foreach (const config *item, cfg.get_children("binary_path"))
+       {
+               std::string path = (*item)["path"].str();
+               if (path.find("..") != std::string::npos) {
+                       ERR_FS << "Invalid binary path '" << path << "'\n";
+                       continue;
+               }
                if (!path.empty() && path[path.size()-1] != '/') path += "/";
                if(binary_paths.count(path) == 0) {
                        binary_paths.insert(path);
@@ -952,15 +956,23 @@
                return itor->second;
        }
 
+       if (type.find("..") != std::string::npos) {
+               // Not an assertion, as language.cpp is passing user data as 
type.
+               ERR_FS << "Invalid WML type '" << type << "' for binary 
paths\n";
+               static std::vector<std::string> dummy;
+               return dummy;
+       }
+
        std::vector<std::string>& res = binary_paths_cache[type];
 
        init_binary_paths();
 
-       for(std::set<std::string>::const_iterator i = binary_paths.begin(); i 
!= binary_paths.end(); ++i) {
-               res.push_back(get_user_data_dir() + "/" + *i + type + "/");
+       foreach (const std::string &path, binary_paths)
+       {
+               res.push_back(get_user_data_dir() + "/" + path + type + "/");
 
                if(!game_config::path.empty()) {
-                       res.push_back(game_config::path + "/" + *i + type + 
"/");
+                       res.push_back(game_config::path + "/" + path + type + 
"/");
                }
        }
 




Related Messages


Powered by MHonArc, Updated Tue Mar 03 19:00:07 2009