Merge branch 'ticket/bantu/7538' into develop-olympus

* ticket/bantu/7538:
  [ticket/7538] Limit user_login_attempts to prevent SQL errors.
This commit is contained in:
Igor Wiedler 2010-10-17 21:32:20 +02:00
commit 2895ade566
2 changed files with 8 additions and 2 deletions

View file

@ -134,7 +134,8 @@ function login_db(&$username, &$password)
// increase login attempt count to make sure this cannot be exploited // increase login attempt count to make sure this cannot be exploited
$sql = 'UPDATE ' . USERS_TABLE . ' $sql = 'UPDATE ' . USERS_TABLE . '
SET user_login_attempts = user_login_attempts + 1 SET user_login_attempts = user_login_attempts + 1
WHERE user_id = ' . $row['user_id']; WHERE user_id = ' . (int) $row['user_id'] . '
AND user_login_attempts < ' . LOGIN_ATTEMPTS_MAX;
$db->sql_query($sql); $db->sql_query($sql);
return array( return array(
@ -194,7 +195,8 @@ function login_db(&$username, &$password)
// Password incorrect - increase login attempts // Password incorrect - increase login attempts
$sql = 'UPDATE ' . USERS_TABLE . ' $sql = 'UPDATE ' . USERS_TABLE . '
SET user_login_attempts = user_login_attempts + 1 SET user_login_attempts = user_login_attempts + 1
WHERE user_id = ' . $row['user_id']; WHERE user_id = ' . (int) $row['user_id'] . '
AND user_login_attempts < ' . LOGIN_ATTEMPTS_MAX;
$db->sql_query($sql); $db->sql_query($sql);
// Give status about wrong password... // Give status about wrong password...

View file

@ -69,6 +69,10 @@ define('LOGIN_ERROR_ATTEMPTS', 13);
define('LOGIN_ERROR_EXTERNAL_AUTH', 14); define('LOGIN_ERROR_EXTERNAL_AUTH', 14);
define('LOGIN_ERROR_PASSWORD_CONVERT', 15); define('LOGIN_ERROR_PASSWORD_CONVERT', 15);
// Maximum login attempts
// The value is arbitrary, but it has to fit into the user_login_attempts field.
define('LOGIN_ATTEMPTS_MAX', 100);
// Group settings // Group settings
define('GROUP_OPEN', 0); define('GROUP_OPEN', 0);
define('GROUP_CLOSED', 1); define('GROUP_CLOSED', 1);