- bugfix regarding Security Vulnerability did not solve the problem under Linux

This commit is contained in:
Uwe Tews
2018-04-26 21:38:08 +02:00
parent 2e081a51b1
commit c9dbe1d08c

View File

@@ -639,7 +639,8 @@ class Smarty_Security
{
$directory = dirname($this->smarty->_realpath($filepath, true)) . DIRECTORY_SEPARATOR;
$_directory = array();
while (true) {
if (!preg_match('#[\\\\/][.][.][\\\\/]#',$directory)) {
while (true) {
// test if the directory is trusted
if (isset($dirs[ $directory ])) {
return $_directory;
@@ -647,13 +648,16 @@ class Smarty_Security
// abort if we've reached root
if (!preg_match('#[\\\\/][^\\\\/]+[\\\\/]$#', $directory)) {
// give up
throw new SmartyException(sprintf('Smarty Security: not trusted file path \'%s\' ',$filepath));
break;
}
// remember the directory to add it to _resource_dir in case we're successful
$_directory[ $directory ] = true;
// bubble up one level
$directory = preg_replace('#[\\\\/][^\\\\/]+[\\\\/]$#', DIRECTORY_SEPARATOR, $directory);
}
}
// give up
throw new SmartyException(sprintf('Smarty Security: not trusted file path \'%s\' ',$filepath));
}
/**