Skip to content

Commit 26413e6

Browse files
committed
extract strlen check from loop
1 parent 3adb3e5 commit 26413e6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/TwoFactorAuth.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,8 @@ private function codeEquals(string $safe, string $user): bool
218218
// we don't leak information about the difference of the two strings.
219219
if (strlen($safe) === strlen($user)) {
220220
$result = 0;
221-
for ($i = 0; $i < strlen($safe); $i++) {
221+
$strlen = strlen($safe);
222+
for ($i = 0; $i < $strlen; $i++) {
222223
$result |= (ord($safe[$i]) ^ ord($user[$i]));
223224
}
224225
return $result === 0;

0 commit comments

Comments
 (0)