Skip to content

Commit c5e9672

Browse files
committed
patch
1 parent 73f3a1c commit c5e9672

File tree

5 files changed

+38
-31
lines changed

5 files changed

+38
-31
lines changed

ext/standard/crypt.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ PHP_MSHUTDOWN_FUNCTION(crypt) /* {{{ */
6767
}
6868
/* }}} */
6969

70-
PHPAPI zend_string *php_crypt(const char *password, size_t pass_len, const char *salt, size_t salt_len, bool quiet)
70+
PHPAPI zend_string *php_crypt(const char *password, size_t pass_len, const char *salt, int salt_len, bool quiet)
7171
{
7272
char *crypt_res;
7373
zend_string *result;
@@ -206,8 +206,8 @@ PHP_FUNCTION(crypt)
206206
zend_string *result;
207207

208208
ZEND_PARSE_PARAMETERS_START(2, 2)
209-
Z_PARAM_STRING(str, str_len)
210-
Z_PARAM_STRING(salt_in, salt_in_len)
209+
Z_PARAM_PATH(str, str_len)
210+
Z_PARAM_PATH(salt_in, salt_in_len)
211211
ZEND_PARSE_PARAMETERS_END();
212212

213213
salt[0] = salt[PHP_MAX_SALT_LEN] = '\0';

ext/standard/tests/password/password_bcrypt_null_verify.phpt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
password_* handles bcrypt passwords containing null bytes
33
--SKIPIF--
44
<?php
5-
$setting = '$2y$05$CCCCCCCCCCCCCCCCCCCCC.';
6-
if (crypt("foo\0bar", $setting) === crypt("foo", $setting)) {
5+
$password = "foo\0bar";
6+
$hash = password_hash($password, PASSWORD_BCRYPT);
7+
if (!is_string($hash) || !password_verify($password, $hash) || password_verify("foo", $hash)) {
78
die("skip bcrypt backend truncates NUL bytes");
89
}
910
?>

ext/standard/tests/strings/bug62443.phpt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,18 @@
22
Bug #62443 Crypt SHA256/512 Segfaults With Malformed Salt
33
--FILE--
44
<?php
5-
crypt("foo", '$5$'.chr(0).'abc');
6-
crypt("foo", '$6$'.chr(0).'abc');
7-
echo "OK!";
5+
try {
6+
crypt("foo", '$5$'.chr(0).'abc');
7+
} catch (ValueError $e) {
8+
echo $e->getMessage(), "\n";
9+
}
10+
11+
try {
12+
crypt("foo", '$6$'.chr(0).'abc');
13+
} catch (ValueError $e) {
14+
echo $e->getMessage(), "\n";
15+
}
816
?>
917
--EXPECT--
10-
OK!
18+
crypt(): Argument #2 ($salt) must not contain any null bytes
19+
crypt(): Argument #2 ($salt) must not contain any null bytes

ext/standard/tests/strings/crypt_blowfish_null.phpt

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
crypt() rejects passwords and salts containing null bytes
3+
--FILE--
4+
<?php
5+
try {
6+
crypt("foo\0bar", '$2y$05$CCCCCCCCCCCCCCCCCCCCC.');
7+
} catch (ValueError $e) {
8+
echo $e->getMessage(), "\n";
9+
}
10+
11+
try {
12+
crypt("foo", '$2y$05$CCCCCCCCCCC' . "\0" . 'CCCCCCC.');
13+
} catch (ValueError $e) {
14+
echo $e->getMessage(), "\n";
15+
}
16+
?>
17+
--EXPECT--
18+
crypt(): Argument #1 ($string) must not contain any null bytes
19+
crypt(): Argument #2 ($salt) must not contain any null bytes

0 commit comments

Comments
 (0)