Skip to content

Commit 295303b

Browse files
committed
Fixed bug #72703 Out of bounds global memory read in BF_crypt triggered by password_verify
1 parent 1a840b9 commit 295303b

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

ext/standard/crypt.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,14 @@ PHPAPI int php_crypt(const char *password, const int pass_len, const char *salt,
201201
salt[5] >= '0' && salt[5] <= '9' &&
202202
salt[6] == '$') {
203203
char output[PHP_MAX_SALT_LEN + 1];
204+
int k = 7;
205+
206+
while (isalnum(salt[k]) || '.' == salt[k] || '/' == salt[k]) {
207+
k++;
208+
}
209+
if (k != salt_len) {
210+
return FAILURE;
211+
}
204212

205213
memset(output, 0, PHP_MAX_SALT_LEN + 1);
206214

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Bug #72703 Out of bounds global memory read in BF_crypt triggered by password_verify
3+
--SKIPIF--
4+
<?php
5+
if (!function_exists('crypt'))) {
6+
die("SKIP crypt() is not available");
7+
}
8+
?>
9+
--FILE--
10+
<?php
11+
var_dump(password_verify("","$2y$10$$"));
12+
?>
13+
==OK==
14+
--EXPECT--
15+
bool(false)
16+
==OK==
17+

0 commit comments

Comments
 (0)