reenable ".." in get_binary_file_location

this was also how ".." behaved in the old code.
This commit is contained in:
gfgtdf 2014-10-18 04:17:01 +02:00 committed by Chris Beck
parent 5db8126caf
commit c2f6072b9b

View file

@ -830,6 +830,16 @@ const std::vector<std::string>& get_binary_paths(const std::string& type)
std::string get_binary_file_location(const std::string& type, const std::string& filename)
{
// We define ".." as "remove everything before" this is needed becasue
// on the one hand allowing ".." would be a security risk but
// especialy for terrains the c++ engine puts a hardcoded "terrain/" before filename
// and there would be no way to "escape" from "terrain/" otherwise. This is not the
// best solution but we cannot remove it without another solution (subtypes maybe?).
// using 'for' instead 'if' to allow putting delcaration and check into the brackets
for(std::string::size_type pos = filename.rfind("../"); pos != std::string::npos;)
return get_binary_file_location(type, filename.substr(pos + 3));
if (!is_legal_file(filename))
return std::string();