From 8d5fa36a80ec35f8a2cde9580746eb7d5508149a Mon Sep 17 00:00:00 2001 From: Uwe Tews Date: Wed, 21 Jan 2015 22:14:25 +0100 Subject: [PATCH] - bugfix clearCompiledTemplates(), clearAll() and clear() could try to delete whole drive at wrong path permissions because realpath() fail (forum 25397) --- change_log.txt | 4 ++-- libs/sysplugins/smarty_internal_cacheresource_file.php | 4 ++-- libs/sysplugins/smarty_internal_utility.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/change_log.txt b/change_log.txt index 8029c361..b270d6b4 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,7 +1,7 @@  ===== 3.1.22-dev ===== (xx.xx.2015) - 20.01.2015 - - bugfix clearCompiledTemplates() could try to delete whole drive at wrong path permissions because realpath() fail (forum 25397) + 21.01.2015 + - bugfix clearCompiledTemplates(), clearAll() and clear() could try to delete whole drive at wrong path permissions because realpath() fail (forum 25397) 04.01.2015 - push last weeks changes to github diff --git a/libs/sysplugins/smarty_internal_cacheresource_file.php b/libs/sysplugins/smarty_internal_cacheresource_file.php index 7af98dc1..cbb38e3b 100644 --- a/libs/sysplugins/smarty_internal_cacheresource_file.php +++ b/libs/sysplugins/smarty_internal_cacheresource_file.php @@ -163,10 +163,10 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource $_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!', '_', $compile_id) : null; $_dir_sep = $smarty->use_sub_dirs ? '/' : '^'; $_compile_id_offset = $smarty->use_sub_dirs ? 3 : 0; - if (($_dir = realpath($smarty->getCacheDir())) === false) { + $_dir = realpath($smarty->getCacheDir()) . '/'; + if ($_dir == '/') { //We should never want to delete this! return 0; } - $_dir .= '/'; $_dir_length = strlen($_dir); if (isset($_cache_id)) { $_cache_id_parts = explode('|', $_cache_id); diff --git a/libs/sysplugins/smarty_internal_utility.php b/libs/sysplugins/smarty_internal_utility.php index af02b095..cd027dec 100644 --- a/libs/sysplugins/smarty_internal_utility.php +++ b/libs/sysplugins/smarty_internal_utility.php @@ -191,10 +191,10 @@ class Smarty_Internal_Utility */ public static function clearCompiledTemplate($resource_name, $compile_id, $exp_time, Smarty $smarty) { - if (($_compile_dir = realpath($smarty->getCompileDir())) === false) { + $_compile_dir = realpath($smarty->getCompileDir()) . '/'; + if ($_compile_dir == '/') { //We should never want to delete this! return 0; } - $_compile_dir .= '/'; $_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!', '_', $compile_id) : null; $_dir_sep = $smarty->use_sub_dirs ? '/' : '^'; if (isset($resource_name)) {