More escaping of username and password.

Improves upon 89fbcd7c39

Signed-off-by: Isaac Bennetch <bennetch@gmail.com>
This commit is contained in:
Isaac Bennetch 2020-03-18 22:16:53 -04:00
parent 0184c2884e
commit 3258978c38
2 changed files with 10 additions and 8 deletions

View File

@ -1971,8 +1971,8 @@ class Privileges
. " `authentication_string` = '" . $hashedPassword
. "', `Password` = '', "
. " `plugin` = '" . $authentication_plugin . "'"
. " WHERE `User` = '" . $username . "' AND Host = '"
. $hostname . "';";
. " WHERE `User` = '" . $GLOBALS['dbi']->escapeString($username)
. "' AND Host = '" . $GLOBALS['dbi']->escapeString($hostname) . "';";
} else {
// USE 'SET PASSWORD ...' syntax for rest of the versions
// Backup the old value, to be reset later
@ -1982,8 +1982,8 @@ class Privileges
$orig_value = $row['@@old_passwords'];
$update_plugin_query = "UPDATE `mysql`.`user` SET"
. " `plugin` = '" . $authentication_plugin . "'"
. " WHERE `User` = '" . $username . "' AND Host = '"
. $hostname . "';";
. " WHERE `User` = '" . $GLOBALS['dbi']->escapeString($username)
. "' AND Host = '" . $GLOBALS['dbi']->escapeString($hostname) . "';";
// Update the plugin for the user
if (!($GLOBALS['dbi']->tryQuery($update_plugin_query))) {

View File

@ -114,7 +114,8 @@ class UserPassword
if ($serverType == 'MySQL'
&& $serverVersion >= 50706
) {
$sql_query = 'ALTER USER \'' . $username . '\'@\'' . $hostname
$sql_query = 'ALTER USER \'' . $GLOBALS['dbi']->escapeString($username)
. '\'@\'' . $GLOBALS['dbi']->escapeString($hostname)
. '\' IDENTIFIED WITH ' . $orig_auth_plugin . ' BY '
. (($password == '') ? '\'\'' : '\'***\'');
} elseif (($serverType == 'MySQL'
@ -182,7 +183,8 @@ class UserPassword
$serverVersion = $GLOBALS['dbi']->getVersion();
if ($serverType == 'MySQL' && $serverVersion >= 50706) {
$local_query = 'ALTER USER \'' . $username . '\'@\'' . $hostname . '\''
$local_query = 'ALTER USER \'' . $GLOBALS['dbi']->escapeString($username)
. '\'@\'' . $GLOBALS['dbi']->escapeString($hostname) . '\''
. ' IDENTIFIED with ' . $orig_auth_plugin . ' BY '
. (($password == '')
? '\'\''
@ -208,8 +210,8 @@ class UserPassword
. " `authentication_string` = '" . $hashedPassword
. "', `Password` = '', "
. " `plugin` = '" . $orig_auth_plugin . "'"
. " WHERE `User` = '" . $username . "' AND Host = '"
. $hostname . "';";
. " WHERE `User` = '" . $GLOBALS['dbi']->escapeString($username)
. "' AND Host = '" . $GLOBALS['dbi']->escapeString($hostname) . "';";
} else {
$local_query = 'SET password = ' . (($password == '')
? '\'\''