Prevent high resource usage when hashing large passwords. props mdawaffe, pento

Merges [30466] to the 4.0 branch.

Built from https://develop.svn.wordpress.org/branches/4.0@30467


git-svn-id: http://core.svn.wordpress.org/branches/4.0@30458 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2014-11-20 16:05:39 +00:00
parent 6e658f81cf
commit 39c7ff2304
1 changed files with 8 additions and 0 deletions

View File

@ -214,6 +214,10 @@ class PasswordHash {
function HashPassword($password)
{
if ( strlen( $password ) > 4096 ) {
return '*';
}
$random = '';
if (CRYPT_BLOWFISH == 1 && !$this->portable_hashes) {
@ -249,6 +253,10 @@ class PasswordHash {
function CheckPassword($password, $stored_hash)
{
if ( strlen( $password ) > 4096 ) {
return false;
}
$hash = $this->crypt_private($password, $stored_hash);
if ($hash[0] == '*')
$hash = crypt($password, $stored_hash);