From 85f24ce413a3b68e45f2f0a513f472c8c6ce0c96 Mon Sep 17 00:00:00 2001 From: Uwe Tews Date: Wed, 21 Jan 2015 21:12:00 +0100 Subject: [PATCH] convert writeFile() to object method to remove a vulnerability --- libs/sysplugins/smarty_internal_cacheresource_file.php | 3 ++- libs/sysplugins/smarty_internal_write_file.php | 2 +- libs/sysplugins/smarty_template_compiled.php | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libs/sysplugins/smarty_internal_cacheresource_file.php b/libs/sysplugins/smarty_internal_cacheresource_file.php index 5354a03b..7af98dc1 100644 --- a/libs/sysplugins/smarty_internal_cacheresource_file.php +++ b/libs/sysplugins/smarty_internal_cacheresource_file.php @@ -106,7 +106,8 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource */ public function writeCachedContent(Smarty_Internal_Template $_template, $content) { - if (Smarty_Internal_Write_File::writeFile($_template->cached->filepath, $content, $_template->smarty) === true) { + $obj = new Smarty_Internal_Write_File(); + if ($obj->writeFile($_template->cached->filepath, $content, $_template->smarty) === true) { $_template->cached->timestamp = @filemtime($_template->cached->filepath); $_template->cached->exists = !!$_template->cached->timestamp; if ($_template->cached->exists) { diff --git a/libs/sysplugins/smarty_internal_write_file.php b/libs/sysplugins/smarty_internal_write_file.php index f46fe2b6..54dbbe8f 100644 --- a/libs/sysplugins/smarty_internal_write_file.php +++ b/libs/sysplugins/smarty_internal_write_file.php @@ -25,7 +25,7 @@ class Smarty_Internal_Write_File * @throws SmartyException * @return boolean true */ - public static function writeFile($_filepath, $_contents, Smarty $smarty) + public function writeFile($_filepath, $_contents, Smarty $smarty) { $_error_reporting = error_reporting(); error_reporting($_error_reporting & ~E_NOTICE & ~E_WARNING); diff --git a/libs/sysplugins/smarty_template_compiled.php b/libs/sysplugins/smarty_template_compiled.php index 16b34feb..3a3cbd3b 100644 --- a/libs/sysplugins/smarty_template_compiled.php +++ b/libs/sysplugins/smarty_template_compiled.php @@ -247,7 +247,8 @@ class Smarty_Template_Compiled public function write(Smarty_Internal_Template $_template, $code) { if (!$_template->source->recompiled) { - if (Smarty_Internal_Write_File::writeFile($this->filepath, $code, $_template->smarty) === true) { + $obj = new Smarty_Internal_Write_File(); + if ($obj->writeFile($this->filepath, $code, $_template->smarty) === true) { $this->timestamp = @filemtime($this->filepath); $this->exists = !!$this->timestamp; if ($this->exists) {