From 8ac57b1281250cbf3f0eee3db23fed281ad2ba3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Tue, 12 Jul 2016 17:35:56 +0200 Subject: [PATCH] Correctly escape MySQL username in queries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Čihař --- libraries/RecentTable.class.php | 2 +- libraries/Table.class.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/RecentTable.class.php b/libraries/RecentTable.class.php index fef75084ce..fd396bcf78 100644 --- a/libraries/RecentTable.class.php +++ b/libraries/RecentTable.class.php @@ -84,7 +84,7 @@ class PMA_RecentTable // Read from phpMyAdmin database, if recent tables is not in session $sql_query = " SELECT `tables` FROM " . $this->_pmaTable . - " WHERE `username` = '" . $GLOBALS['cfg']['Server']['user'] . "'"; + " WHERE `username` = '" . PMA_Util::sqlAddSlashes($GLOBALS['cfg']['Server']['user']) . "'"; $return = array(); $result = PMA_queryAsControlUser($sql_query, false); diff --git a/libraries/Table.class.php b/libraries/Table.class.php index 7fdbf78f19..e6cb98b79d 100644 --- a/libraries/Table.class.php +++ b/libraries/Table.class.php @@ -250,7 +250,7 @@ class PMA_Table $analyzed_sql = array(); if (self::isView($db, $table)) { // For a view, 'SHOW CREATE TABLE' returns the definition, - // but the structure of the view. So, we try to mock + // but the structure of the view. So, we try to mock // the result of analyzing 'SHOW CREATE TABLE' query. $analyzed_sql[0] = array(); $analyzed_sql[0]['create_table_fields'] = array(); @@ -1411,7 +1411,7 @@ class PMA_Table // Read from phpMyAdmin database $sql_query = " SELECT `prefs` FROM " . $pma_table - . " WHERE `username` = '" . $GLOBALS['cfg']['Server']['user'] . "'" + . " WHERE `username` = '" . PMA_Util::sqlAddSlashes($GLOBALS['cfg']['Server']['user']) . "'" . " AND `db_name` = '" . PMA_Util::sqlAddSlashes($this->db_name) . "'" . " AND `table_name` = '" . PMA_Util::sqlAddSlashes($this->name) . "'"; @@ -1435,7 +1435,7 @@ class PMA_Table $username = $GLOBALS['cfg']['Server']['user']; $sql_query = " REPLACE INTO " . $pma_table - . " VALUES ('" . $username . "', '" . PMA_Util::sqlAddSlashes($this->db_name) + . " VALUES ('" . PMA_Util::sqlAddSlashes($username) . "', '" . PMA_Util::sqlAddSlashes($this->db_name) . "', '" . PMA_Util::sqlAddSlashes($this->name) . "', '" . PMA_Util::sqlAddSlashes(json_encode($this->uiprefs)) . "', NULL)"; @@ -1647,7 +1647,7 @@ class PMA_Table /** * Get all column names which are MySQL reserved words - * + * * @return array * @access public */ @@ -1661,7 +1661,7 @@ class PMA_Table if (PMA_SQP_isKeyWord($column_name)) { $return[] = $column_name; } - } + } return $return; } }