Skip to content

Commit a92acba

Browse files
TimWollasmalyshev
authored andcommitted
crypt: Fix possible buffer overread in php_crypt()
1 parent c840f71 commit a92acba

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

ext/standard/crypt.c

+1
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ PHPAPI zend_string *php_crypt(const char *password, const int pass_len, const ch
135135
} else if (
136136
salt[0] == '$' &&
137137
salt[1] == '2' &&
138+
salt[2] != 0 &&
138139
salt[3] == '$') {
139140
char output[PHP_MAX_SALT_LEN + 1];
140141

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
--TEST--
2+
Test that password_hash() does not overread buffers when a short hash is passed
3+
--FILE--
4+
<?php
5+
var_dump(password_verify("foo", '$2'));
6+
?>
7+
--EXPECT--
8+
bool(false)

0 commit comments

Comments
 (0)