extract strlen check from loop

This commit is contained in:
Mark Magyar
2023-05-27 21:14:31 +02:00
parent 3adb3e54e5
commit 26413e69f0
+2 -1
View File
@@ -218,7 +218,8 @@ class TwoFactorAuth
// we don't leak information about the difference of the two strings.
if (strlen($safe) === strlen($user)) {
$result = 0;
for ($i = 0; $i < strlen($safe); $i++) {
$strlen = strlen($safe);
for ($i = 0; $i < $strlen; $i++) {
$result |= (ord($safe[$i]) ^ ord($user[$i]));
}
return $result === 0;