- rewrite mkdir() bugfix to retry automatically see https://github.com/smarty-php/smarty/pull/377

https://github.com/smarty-php/smarty/pull/379
This commit is contained in:
Uwe Tews
2017-07-30 05:16:31 +02:00
parent 5165776aec
commit bcfea52cbf
3 changed files with 19 additions and 4 deletions

View File

@@ -1,4 +1,8 @@
===== 3.1.32 - dev === ===== 3.1.32 - dev ===
30.7.2017
- rewrite mkdir() bugfix to retry automatically see https://github.com/smarty-php/smarty/pull/377
https://github.com/smarty-php/smarty/pull/379
21.7.2017 21.7.2017
- security possible PHP code injection on custom resources at display() or fetch() - security possible PHP code injection on custom resources at display() or fetch()
calls if the resource does not sanitize the template name calls if the resource does not sanitize the template name

View File

@@ -108,7 +108,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/** /**
* smarty version * smarty version
*/ */
const SMARTY_VERSION = '3.1.32-dev-14'; const SMARTY_VERSION = '3.1.32-dev-15';
/** /**
* define variable scopes * define variable scopes

View File

@@ -39,10 +39,21 @@ class Smarty_Internal_Runtime_WriteFile
$_dirpath = dirname($_filepath); $_dirpath = dirname($_filepath);
// if subdirs, create dir structure // if subdirs, create dir structure
if ($_dirpath !== '.' && !@mkdir($_dirpath, $_dir_perms, true) && !is_dir($_dirpath)) { if ($_dirpath !== '.') {
$i=0;
// loop if concurrency problem occurs
// see https://bugs.php.net/bug.php?id=35326
while (!is_dir($_dirpath)) {
if (@mkdir($_dirpath, $_dir_perms, true)) {
break;
}
if (++$i === 3) {
error_reporting($_error_reporting); error_reporting($_error_reporting);
throw new SmartyException("unable to create directory {$_dirpath}"); throw new SmartyException("unable to create directory {$_dirpath}");
} }
sleep(1);
}
}
// write to tmp file, then move to overt file lock race condition // write to tmp file, then move to overt file lock race condition
$_tmp_file = $_dirpath . $smarty->ds . str_replace(array('.', ','), '_', uniqid('wrt', true)); $_tmp_file = $_dirpath . $smarty->ds . str_replace(array('.', ','), '_', uniqid('wrt', true));