mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0: Bug #73058 crypt broken when salt is 'too' long
This commit is contained in:
commit
435048935e
3 changed files with 33 additions and 8 deletions
|
@ -158,14 +158,6 @@ PHPAPI zend_string *php_crypt(const char *password, const int pass_len, const ch
|
|||
salt[1] == '2' &&
|
||||
salt[3] == '$') {
|
||||
char output[PHP_MAX_SALT_LEN + 1];
|
||||
int k = 7;
|
||||
|
||||
while (isalnum(salt[k]) || '.' == salt[k] || '/' == salt[k]) {
|
||||
k++;
|
||||
}
|
||||
if (k != salt_len) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(output, 0, PHP_MAX_SALT_LEN + 1);
|
||||
|
||||
|
|
|
@ -405,6 +405,10 @@ static int BF_decode(BF_word *dst, const char *src, int size)
|
|||
*dptr++ = ((c3 & 0x03) << 6) | c4;
|
||||
} while (dptr < end);
|
||||
|
||||
if (end - dptr == size) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (dptr < end) /* PHP hack */
|
||||
*dptr++ = 0;
|
||||
|
||||
|
|
29
ext/standard/tests/strings/bug73058.phpt
Normal file
29
ext/standard/tests/strings/bug73058.phpt
Normal file
|
@ -0,0 +1,29 @@
|
|||
--TEST--
|
||||
Bug #73058 crypt broken when salt is 'too' long
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!function_exists('crypt'))) {
|
||||
die("SKIP crypt() is not available");
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$pass = 'secret';
|
||||
|
||||
$salt = '$2y$07$usesomesillystringforsalt$';
|
||||
var_dump(crypt($pass, $salt));
|
||||
|
||||
$salt = '$2y$07$usesomesillystringforsaltzzzzzzzzzzzzz$';
|
||||
var_dump(crypt($pass, $salt));
|
||||
|
||||
$salt = '$2y$07$usesomesillystringforx';
|
||||
var_dump(crypt($pass, $salt));
|
||||
|
||||
?>
|
||||
==OK==
|
||||
--EXPECT--
|
||||
string(60) "$2y$07$usesomesillystringforex.u2VJUMLRWaJNuw0Hu2FvCEimdeYVO"
|
||||
string(60) "$2y$07$usesomesillystringforex.u2VJUMLRWaJNuw0Hu2FvCEimdeYVO"
|
||||
string(60) "$2y$07$usesomesillystringforuw2Gm1ef7lMsvtzSK2p/14F0q1e8uOCO"
|
||||
==OK==
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue