mirror of
https://github.com/php/php-src.git
synced 2025-08-18 23:18:56 +02:00
fix crypt() issue with overlong salt
This commit is contained in:
parent
adabdede5e
commit
01249bb40b
2 changed files with 25 additions and 0 deletions
|
@ -179,6 +179,8 @@ PHP_FUNCTION(crypt)
|
||||||
salt[2] = '\0';
|
salt[2] = '\0';
|
||||||
#endif
|
#endif
|
||||||
salt_in_len = strlen(salt);
|
salt_in_len = strlen(salt);
|
||||||
|
} else {
|
||||||
|
salt_in_len = MIN(PHP_MAX_SALT_LEN, salt_in_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Windows (win32/crypt) has a stripped down version of libxcrypt and
|
/* Windows (win32/crypt) has a stripped down version of libxcrypt and
|
||||||
|
|
23
ext/standard/tests/strings/crypt_variation1.phpt
Normal file
23
ext/standard/tests/strings/crypt_variation1.phpt
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
--TEST--
|
||||||
|
crypt() function - long salt
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!function_exists('crypt')) {
|
||||||
|
die("SKIP crypt() is not available");
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$b = str_repeat("A", 124);
|
||||||
|
echo crypt("A", "$5$" . $b)."\n";
|
||||||
|
$b = str_repeat("A", 125);
|
||||||
|
echo crypt("A", "$5$" . $b)."\n";
|
||||||
|
$b = str_repeat("A", 4096);
|
||||||
|
echo crypt("A", "$5$" . $b)."\n";
|
||||||
|
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
$5$AAAAAAAAAAAAAAAA$frotiiztWZiwcncxnY5tWG9Ida2WOZEximjLXCleQu6
|
||||||
|
$5$AAAAAAAAAAAAAAAA$frotiiztWZiwcncxnY5tWG9Ida2WOZEximjLXCleQu6
|
||||||
|
$5$AAAAAAAAAAAAAAAA$frotiiztWZiwcncxnY5tWG9Ida2WOZEximjLXCleQu6
|
Loading…
Add table
Add a link
Reference in a new issue