mirror of
https://github.com/phpbb/phpbb.git
synced 2025-04-12 20:02:08 +02:00
Merge branch 'ticket/11873' into prep-release-3.0.12
* ticket/11873: [ticket/11873] Add unit test for large password input. [ticket/11873] Do not hash very large passwords in order to safe resources.
This commit is contained in:
commit
426994a7f8
@ -502,6 +502,13 @@ function phpbb_hash($password)
|
||||
*/
|
||||
function phpbb_check_hash($password, $hash)
|
||||
{
|
||||
if (strlen($password) > 4096)
|
||||
{
|
||||
// If the password is too huge, we will simply reject it
|
||||
// and not let the server try to hash it.
|
||||
return false;
|
||||
}
|
||||
|
||||
$itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
||||
if (strlen($hash) == 34)
|
||||
{
|
||||
|
@ -17,5 +17,13 @@ class phpbb_security_hash_test extends phpbb_test_case
|
||||
$this->assertTrue(phpbb_check_hash('test', '$P$9isfrtKXWqrz8PvztXlL3.daw4U0zI1'));
|
||||
$this->assertFalse(phpbb_check_hash('foo', '$H$9isfrtKXWqrz8PvztXlL3.daw4U0zI1'));
|
||||
}
|
||||
|
||||
public function test_check_hash_with_large_input()
|
||||
{
|
||||
// 16 MB password, should be rejected quite fast
|
||||
$start_time = time();
|
||||
$this->assertFalse(phpbb_check_hash(str_repeat('a', 1024 * 1024 * 16), '$H$9isfrtKXWqrz8PvztXlL3.daw4U0zI1'));
|
||||
$this->assertLessThanOrEqual(5, time() - $start_time);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user