Skip to content
This repository has been archived by the owner on Dec 21, 2022. It is now read-only.

Commit

Permalink
Merge pull request #123 from silverstripe/FIX/consistent_response_times
Browse files Browse the repository at this point in the history
Ensure time comparisons use floats
  • Loading branch information
Stig Lindqvist authored Jan 8, 2018
2 parents 31e670c + e030e6e commit 6314686
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions code/authenticators/LDAPLoginForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ public function __construct($controller, $name, $fields = null, $actions = null,
*/
public function forgotPassword($data)
{
$startTime = microtime();
// Passing true returns a float rather than a string
$startTime = microtime(true);
// No need to protect against injections, LDAPService will ensure that this is safe
$login = trim($data['Login']);

Expand Down Expand Up @@ -210,7 +211,7 @@ protected function consistentResponseTime($startTime)
return;
}

$timeTaken = microtime() - $startTime;
$timeTaken = microtime(true) - $startTime;
if ($timeTaken < self::RESPONSE_TIME) {
$sleepTime = self::RESPONSE_TIME - $timeTaken;
// usleep takes microseconds, so we times our sleep period by 1mil (1mil ms = 1s)
Expand Down

0 comments on commit 6314686

Please sign in to comment.