From 26413e69f0f7574af5c2b5f5e69c91161df0a85f Mon Sep 17 00:00:00 2001 From: Mark Magyar <14284867+xHeaven@users.noreply.github.com> Date: Sat, 27 May 2023 21:14:31 +0200 Subject: [PATCH] extract strlen check from loop --- lib/TwoFactorAuth.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/TwoFactorAuth.php b/lib/TwoFactorAuth.php index a9820d1..0c7534d 100644 --- a/lib/TwoFactorAuth.php +++ b/lib/TwoFactorAuth.php @@ -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;