mirror of
https://github.com/pi-hole/web.git
synced 2025-12-26 13:36:22 +00:00
Use hash_equals in password.php (and move it to funcs.php)
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
This commit is contained in:
@@ -92,26 +92,6 @@ function check_csrf($token) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
// Credit: http://php.net/manual/en/function.hash-equals.php#119576
|
||||
if(!function_exists('hash_equals')) {
|
||||
function hash_equals($known_string, $user_string) {
|
||||
$ret = 0;
|
||||
|
||||
if (strlen($known_string) !== strlen($user_string)) {
|
||||
$user_string = $known_string;
|
||||
$ret = 1;
|
||||
}
|
||||
|
||||
$res = $known_string ^ $user_string;
|
||||
|
||||
for ($i = strlen($res) - 1; $i >= 0; --$i) {
|
||||
$ret |= ord($res[$i]);
|
||||
}
|
||||
|
||||
return !$ret;
|
||||
}
|
||||
}
|
||||
|
||||
if(!isset($_SESSION['token']) || empty($token) || !hash_equals($_SESSION['token'], $token)) {
|
||||
log_and_die("Wrong token");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user