From 53b1f9adcc5882838161d3aa6289d93385053fbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 12 Feb 2016 13:24:39 +0100 Subject: [PATCH] Silent errors on checking for files and folders MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #11951 Fixes #11952 Signed-off-by: Michal Čihař --- ChangeLog | 2 ++ changelog.php | 2 +- import.php | 2 +- libraries/Config.class.php | 4 ++-- libraries/File.class.php | 7 ++----- libraries/export.lib.php | 2 +- libraries/file_listing.lib.php | 2 +- libraries/plugins/import/ImportShp.class.php | 2 +- license.php | 2 +- prefs_manage.php | 2 +- setup/lib/index.lib.php | 6 +++--- 11 files changed, 16 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5a6cc33667..84c30901b8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -26,6 +26,8 @@ phpMyAdmin - ChangeLog - issue #11946 Correctly store and report file upload errors - issue #11948 Avoid javascript errors on invalid location hash - issue #11950 Fix PHP warning on configuration errors +- issue #11951 Silent errors on checking for writable folders +- issue #11952 Silent warning on invalid file upload 4.5.4.1 (2016-01-29) - issue #11892 Error with PMA 4.4.15.3 diff --git a/changelog.php b/changelog.php index 6dbd495059..2fb7646bc3 100644 --- a/changelog.php +++ b/changelog.php @@ -20,7 +20,7 @@ $filename = CHANGELOG_FILE; * Read changelog. */ // Check if the file is available, some distributions remove these. -if (is_readable($filename)) { +if (@is_readable($filename)) { // Test if the if is in a compressed format if (substr($filename, -3) == '.gz') { diff --git a/import.php b/import.php index aebba6c937..24ea907838 100644 --- a/import.php +++ b/import.php @@ -450,7 +450,7 @@ if ($import_file != 'none' && ! $error) { $tmp_subdir = sys_get_temp_dir(); } $tmp_subdir = rtrim($tmp_subdir, DIRECTORY_SEPARATOR); - if (is_writable($tmp_subdir)) { + if (@is_writable($tmp_subdir)) { $import_file_new = $tmp_subdir . DIRECTORY_SEPARATOR . basename($import_file) . uniqid(); if (move_uploaded_file($import_file, $import_file_new)) { diff --git a/libraries/Config.class.php b/libraries/Config.class.php index 3691036c2a..07af3b60a6 100644 --- a/libraries/Config.class.php +++ b/libraries/Config.class.php @@ -1166,12 +1166,12 @@ class PMA_Config return false; } - if (! file_exists($this->getSource())) { + if (! @file_exists($this->getSource())) { $this->source_mtime = 0; return false; } - if (! is_readable($this->getSource())) { + if (! @is_readable($this->getSource())) { // manually check if file is readable // might be bug #3059806 Supporting running from CIFS/Samba shares diff --git a/libraries/File.class.php b/libraries/File.class.php index 1929f9603e..8c790378b3 100644 --- a/libraries/File.class.php +++ b/libraries/File.class.php @@ -441,10 +441,7 @@ class PMA_File { // suppress warnings from being displayed, but not from being logged // any file access outside of open_basedir will issue a warning - ob_start(); - $is_readable = is_readable($this->getName()); - ob_end_clean(); - return $is_readable; + return @is_readable($this->getName()); } /** @@ -463,7 +460,7 @@ class PMA_File } if (empty($GLOBALS['cfg']['TempDir']) - || ! is_writable($GLOBALS['cfg']['TempDir']) + || ! @is_writable($GLOBALS['cfg']['TempDir']) ) { // cannot create directory or access, point user to FAQ 1.11 $this->_error_message = __( diff --git a/libraries/export.lib.php b/libraries/export.lib.php index e7ebb13392..be0b05612e 100644 --- a/libraries/export.lib.php +++ b/libraries/export.lib.php @@ -339,7 +339,7 @@ function PMA_openExportFile($filename, $quick_export) ) ); $message->addParam($save_filename); - } elseif (is_file($save_filename) && ! is_writable($save_filename)) { + } elseif (is_file($save_filename) && ! @is_writable($save_filename)) { $message = PMA_Message::error( __( 'The web server does not have permission ' diff --git a/libraries/file_listing.lib.php b/libraries/file_listing.lib.php index 60b1d65ca0..6974bed11d 100644 --- a/libraries/file_listing.lib.php +++ b/libraries/file_listing.lib.php @@ -28,7 +28,7 @@ function PMA_getDirContent($dir, $expression = '') $dir .= '/'; } while ($file = @readdir($handle)) { - if (is_file($dir . $file) + if (@is_file($dir . $file) && ($expression == '' || preg_match($expression, $file)) ) { $result[] = $file; diff --git a/libraries/plugins/import/ImportShp.class.php b/libraries/plugins/import/ImportShp.class.php index 4149105347..6a0384989c 100644 --- a/libraries/plugins/import/ImportShp.class.php +++ b/libraries/plugins/import/ImportShp.class.php @@ -88,7 +88,7 @@ class ImportShp extends ImportPlugin // and use the files in it for import if ($compression == 'application/zip' && ! empty($GLOBALS['cfg']['TempDir']) - && is_writable($GLOBALS['cfg']['TempDir']) + && @is_writable($GLOBALS['cfg']['TempDir']) ) { $dbf_file_name = PMA_findFileFromZipArchive( '/^.*\.dbf$/i', $import_file diff --git a/license.php b/license.php index 7348af874f..62f3a15d48 100644 --- a/license.php +++ b/license.php @@ -22,7 +22,7 @@ header('Content-type: text/plain; charset=utf-8'); $filename = LICENSE_FILE; // Check if the file is available, some distributions remove these. -if (is_readable($filename)) { +if (@is_readable($filename)) { readfile($filename); } else { printf( diff --git a/prefs_manage.php b/prefs_manage.php index a6b2bcdd9b..de1d0341e7 100644 --- a/prefs_manage.php +++ b/prefs_manage.php @@ -58,7 +58,7 @@ if (isset($_POST['submit_export']) // directory if (!empty($open_basedir)) { $tmp_subdir = (PMA_IS_WINDOWS ? '.\\tmp\\' : 'tmp/'); - if (is_writable($tmp_subdir)) { + if (@is_writable($tmp_subdir)) { $import_file_new = tempnam($tmp_subdir, 'prefs'); if (move_uploaded_file($import_file, $import_file_new)) { $import_file = $import_file_new; diff --git a/setup/lib/index.lib.php b/setup/lib/index.lib.php index ac07d27db9..eb81fe75ad 100644 --- a/setup/lib/index.lib.php +++ b/setup/lib/index.lib.php @@ -199,13 +199,13 @@ function PMA_checkConfigRw(&$is_readable, &$is_writable, &$file_exists) $file_path = $GLOBALS['ConfigFile']->getFilePath(); $file_dir = dirname($file_path); $is_readable = true; - $is_writable = is_dir($file_dir); + $is_writable = @is_dir($file_dir); if (SETUP_DIR_WRITABLE) { - $is_writable = $is_writable && is_writable($file_dir); + $is_writable = $is_writable && @is_writable($file_dir); } $file_exists = file_exists($file_path); if ($file_exists) { $is_readable = is_readable($file_path); - $is_writable = $is_writable && is_writable($file_path); + $is_writable = $is_writable && @is_writable($file_path); } }