From 96f5f101cc6db57abaea88f4ff5015f1839a2c8e Mon Sep 17 00:00:00 2001 From: Deven Bansod Date: Thu, 25 Aug 2016 23:25:19 +0530 Subject: [PATCH 1/3] Add error checking in reading the advisory_rules file If the file does not exist or if it is not readable by PHP, it can return FALSE. In such cases, we should print a user-friendly message and return from parsing the rules file. Fix #12476 Signed-off-by: Deven Bansod --- libraries/Advisor.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libraries/Advisor.php b/libraries/Advisor.php index 59742b2f6c..cfe4fa65e5 100644 --- a/libraries/Advisor.php +++ b/libraries/Advisor.php @@ -455,10 +455,20 @@ class Advisor */ public static function parseRulesFile() { - $file = file('libraries/advisory_rules.txt', FILE_IGNORE_NEW_LINES); + $filename = 'libraries/advisory_rules.txt'; + $file = file($filename, FILE_IGNORE_NEW_LINES); + $errors = array(); $rules = array(); $lines = array(); + + if ($file === FALSE) { + $errors[] = __( + 'Error in reading file: The file \'' . $filename .'\' does not exist or is not readable' + ); + return array('rules' => $rules, 'lines' => $lines, 'errors' => $errors); + } + $ruleSyntax = array( 'name', 'formula', 'test', 'issue', 'recommendation', 'justification' ); From b3e7f10f2ed8949512b623cac4055de86fe368fc Mon Sep 17 00:00:00 2001 From: Deven Bansod Date: Thu, 25 Aug 2016 23:59:29 +0530 Subject: [PATCH 2/3] Check if the indices are present and map to a string value Fix #12477 The indices may not be present in the json_decode result, or might not be strings Signed-off-by: Deven Bansod --- libraries/common.inc.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libraries/common.inc.php b/libraries/common.inc.php index 9ec0fc32cd..3c6134afcf 100644 --- a/libraries/common.inc.php +++ b/libraries/common.inc.php @@ -455,9 +455,15 @@ PMA_setGlobalDbOrTable('table'); */ if (PMA_isValid($_REQUEST['selected_recent_table'])) { $recent_table = json_decode($_REQUEST['selected_recent_table'], true); - $GLOBALS['db'] = $recent_table['db']; + + $GLOBALS['db'] + = (array_key_exists('db', $recent_table) && is_string($recent_table['db'])) ? + $recent_table['db'] : ''; $GLOBALS['url_params']['db'] = $GLOBALS['db']; - $GLOBALS['table'] = $recent_table['table']; + + $GLOBALS['table'] + = (array_key_exists('table', $recent_table) && is_string($recent_table['table'])) ? + $recent_table['table'] : ''; $GLOBALS['url_params']['table'] = $GLOBALS['table']; } From d7181d1b5a35bf91053d74babf1a3cef666d894e Mon Sep 17 00:00:00 2001 From: Deven Bansod Date: Fri, 26 Aug 2016 00:04:19 +0530 Subject: [PATCH 3/3] ChangeLog entries for #12476 and #12477 Signed-off-by: Deven Bansod --- ChangeLog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog b/ChangeLog index 7dc6cf9114..413e3f6b6e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,8 @@ phpMyAdmin - ChangeLog - issue #12251 Fixed random logouts due to wrong cookie path - issue #12480 Fixed editing of ENUM/SET/DECIMAL fields structure - issue #12497 Missing escaping of configuration used in SQL (hide_db and only_db) +- issue #12476 Add error checking in reading advisory rules file +- issue #12477 Add checking missing elements and confirming element types from json_decode 4.6.4 (2016-08-16) - issue [security] Weaknesses with cookie encryption, see PMASA-2016-29