- 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,6 +639,7 @@ class Smarty_Security
{ {
$directory = dirname($this->smarty->_realpath($filepath, true)) . DIRECTORY_SEPARATOR; $directory = dirname($this->smarty->_realpath($filepath, true)) . DIRECTORY_SEPARATOR;
$_directory = array(); $_directory = array();
if (!preg_match('#[\\\\/][.][.][\\\\/]#',$directory)) {
while (true) { while (true) {
// test if the directory is trusted // test if the directory is trusted
if (isset($dirs[ $directory ])) { if (isset($dirs[ $directory ])) {
@@ -647,7 +648,7 @@ class Smarty_Security
// abort if we've reached root // abort if we've reached root
if (!preg_match('#[\\\\/][^\\\\/]+[\\\\/]$#', $directory)) { if (!preg_match('#[\\\\/][^\\\\/]+[\\\\/]$#', $directory)) {
// give up // 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 // remember the directory to add it to _resource_dir in case we're successful
$_directory[ $directory ] = true; $_directory[ $directory ] = true;
@@ -655,6 +656,9 @@ class Smarty_Security
$directory = preg_replace('#[\\\\/][^\\\\/]+[\\\\/]$#', DIRECTORY_SEPARATOR, $directory); $directory = preg_replace('#[\\\\/][^\\\\/]+[\\\\/]$#', DIRECTORY_SEPARATOR, $directory);
} }
} }
// give up
throw new SmartyException(sprintf('Smarty Security: not trusted file path \'%s\' ',$filepath));
}
/** /**
* Loads security class and enables security * Loads security class and enables security