From b5a1ddffa0b424d4e8d6b7b08cbbf3eec3d264bb Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 23 Feb 2008 11:45:38 +0000 Subject: [PATCH] Do not rely on parameter returned by unlink() for verifying cache directory write permission - #19565 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8388 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/docs/CHANGELOG.html | 1 + phpBB/includes/acm/acm_file.php | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html index 7e2e1a4663..a7c98dd417 100644 --- a/phpBB/docs/CHANGELOG.html +++ b/phpBB/docs/CHANGELOG.html @@ -123,6 +123,7 @@
  • [Fix] Many minor and/or cosmetic fixes (Including, but not limited to: #21315, #18575, #18435, #21215)
  • [Feature] New option to hide the entire list of subforums on listforums
  • [Fix] Custom BBCode {EMAIL}-Token usage (Bug #21155)
  • +
  • [Fix] Do not rely on parameter returned by unlink() for verifying cache directory write permission (Bug #19565)
  • diff --git a/phpBB/includes/acm/acm_file.php b/phpBB/includes/acm/acm_file.php index 775e8d4495..5851016f3d 100644 --- a/phpBB/includes/acm/acm_file.php +++ b/phpBB/includes/acm/acm_file.php @@ -312,7 +312,7 @@ class acm if ($var_name[0] == '_') { - $this->remove_file($this->cache_dir . 'data' . $var_name . ".$phpEx"); + $this->remove_file($this->cache_dir . 'data' . $var_name . ".$phpEx", true); } else if (isset($this->vars[$var_name])) { @@ -375,7 +375,7 @@ class acm } else if ($expired) { - $this->remove_file($this->cache_dir . 'sql_' . md5($query) . ".$phpEx"); + $this->remove_file($this->cache_dir . 'sql_' . md5($query) . ".$phpEx", true); return false; } @@ -489,13 +489,15 @@ class acm /** * Removes/unlinks file */ - function remove_file($filename) + function remove_file($filename, $check = false) { - if (!@unlink($filename)) + if ($check && !@is_writeable($this->cache_dir)) { // E_USER_ERROR - not using language entry - intended. trigger_error('Unable to remove files within ' . $this->cache_dir . '. Please check directory permissions.', E_USER_ERROR); } + + return @unlink($filename); } }