Fix variable misnomers in MD_STD_SEC

This commit is contained in:
Joshua Ramon Enslin 2022-08-14 16:17:03 +02:00
parent 52aeedd31e
commit ced5a65122
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE

View File

@ -87,7 +87,7 @@ final class MD_STD_SEC {
$delay_micoseconds = max($max - 1, 1) * 1000000;
}
return rand($delay_micoseconds - 100000, $delay_micoseconds);
return max(0, rand($delay_micoseconds - 100000, $delay_micoseconds));
}
@ -97,6 +97,7 @@ final class MD_STD_SEC {
* @param string $tool_name Identifier of the login.
* @param string $username Username to look for.
* @param integer $max_execution_time Optional maximum execution time to stay below.
* In seconds.
*
* @return boolean
*/
@ -154,10 +155,12 @@ final class MD_STD_SEC {
$delay_multiplier_per_ip,
$max_execution_time);
\error_log("Logged in: " . $username . "; Delay: " . ($delay_micoseconds / 1000000) . " seconds");
// Sleep
\usleep($delay_micoseconds);
if ($delay_micoseconds > \abs($max_execution_microseconds - 1000000)) {
if ($delay_micoseconds > \abs($max_execution_time - 1000000)) {
return false;
}