Skip to content

Commit 85d9278

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
2 parents 18b611d + b5ccaaf commit 85d9278

File tree

7 files changed

+96
-13
lines changed

7 files changed

+96
-13
lines changed

ext/dom/document.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,7 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, size_t so
11821182
int validate, recover, resolve_externals, keep_blanks, substitute_ent;
11831183
int resolved_path_len;
11841184
int old_error_reporting = 0;
1185-
char *directory=NULL, resolved_path[MAXPATHLEN];
1185+
char *directory=NULL, resolved_path[MAXPATHLEN + 1];
11861186

11871187
if (id != NULL) {
11881188
intern = Z_DOMOBJ_P(id);

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

ext/standard/crypt_blowfish.c

-8
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,6 @@ static const unsigned char BF_atoi64[0x60] = {
371371
#define BF_safe_atoi64(dst, src) \
372372
{ \
373373
tmp = (unsigned char)(src); \
374-
if (tmp == '$') break; /* PHP hack */ \
375374
if ((unsigned int)(tmp -= 0x20) >= 0x60) return -1; \
376375
tmp = BF_atoi64[tmp]; \
377376
if (tmp > 63) return -1; \
@@ -399,13 +398,6 @@ static int BF_decode(BF_word *dst, const char *src, int size)
399398
*dptr++ = ((c3 & 0x03) << 6) | c4;
400399
} while (dptr < end);
401400

402-
if (end - dptr == size) {
403-
return -1;
404-
}
405-
406-
while (dptr < end) /* PHP hack */
407-
*dptr++ = 0;
408-
409401
return 0;
410402
}
411403

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
--TEST--
2+
bcrypt correctly rejects salts containing $
3+
--FILE--
4+
<?php
5+
for ($i = 0; $i < 23; $i++) {
6+
$salt = '$2y$04$' . str_repeat('0', $i) . '$';
7+
$result = crypt("foo", $salt);
8+
var_dump($salt);
9+
var_dump($result);
10+
var_dump($result === $salt);
11+
}
12+
?>
13+
--EXPECT--
14+
string(8) "$2y$04$$"
15+
string(2) "*0"
16+
bool(false)
17+
string(9) "$2y$04$0$"
18+
string(2) "*0"
19+
bool(false)
20+
string(10) "$2y$04$00$"
21+
string(2) "*0"
22+
bool(false)
23+
string(11) "$2y$04$000$"
24+
string(2) "*0"
25+
bool(false)
26+
string(12) "$2y$04$0000$"
27+
string(2) "*0"
28+
bool(false)
29+
string(13) "$2y$04$00000$"
30+
string(2) "*0"
31+
bool(false)
32+
string(14) "$2y$04$000000$"
33+
string(2) "*0"
34+
bool(false)
35+
string(15) "$2y$04$0000000$"
36+
string(2) "*0"
37+
bool(false)
38+
string(16) "$2y$04$00000000$"
39+
string(2) "*0"
40+
bool(false)
41+
string(17) "$2y$04$000000000$"
42+
string(2) "*0"
43+
bool(false)
44+
string(18) "$2y$04$0000000000$"
45+
string(2) "*0"
46+
bool(false)
47+
string(19) "$2y$04$00000000000$"
48+
string(2) "*0"
49+
bool(false)
50+
string(20) "$2y$04$000000000000$"
51+
string(2) "*0"
52+
bool(false)
53+
string(21) "$2y$04$0000000000000$"
54+
string(2) "*0"
55+
bool(false)
56+
string(22) "$2y$04$00000000000000$"
57+
string(2) "*0"
58+
bool(false)
59+
string(23) "$2y$04$000000000000000$"
60+
string(2) "*0"
61+
bool(false)
62+
string(24) "$2y$04$0000000000000000$"
63+
string(2) "*0"
64+
bool(false)
65+
string(25) "$2y$04$00000000000000000$"
66+
string(2) "*0"
67+
bool(false)
68+
string(26) "$2y$04$000000000000000000$"
69+
string(2) "*0"
70+
bool(false)
71+
string(27) "$2y$04$0000000000000000000$"
72+
string(2) "*0"
73+
bool(false)
74+
string(28) "$2y$04$00000000000000000000$"
75+
string(2) "*0"
76+
bool(false)
77+
string(29) "$2y$04$000000000000000000000$"
78+
string(2) "*0"
79+
bool(false)
80+
string(30) "$2y$04$0000000000000000000000$"
81+
string(60) "$2y$04$000000000000000000000u2a2UpVexIt9k3FMJeAVr3c04F5tcI8K"
82+
bool(false)
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)

ext/xmlreader/php_xmlreader.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ PHP_METHOD(XMLReader, XML)
10171017
xmlreader_object *intern = NULL;
10181018
char *source, *uri = NULL, *encoding = NULL;
10191019
int resolved_path_len, ret = 0;
1020-
char *directory=NULL, resolved_path[MAXPATHLEN];
1020+
char *directory=NULL, resolved_path[MAXPATHLEN + 1];
10211021
xmlParserInputBufferPtr inputbfr;
10221022
xmlTextReaderPtr reader;
10231023

main/fopen_wrappers.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ PHPAPI ZEND_INI_MH(OnUpdateBaseDir)
129129
*/
130130
PHPAPI int php_check_specific_open_basedir(const char *basedir, const char *path)
131131
{
132-
char resolved_name[MAXPATHLEN];
133-
char resolved_basedir[MAXPATHLEN];
132+
char resolved_name[MAXPATHLEN + 1];
133+
char resolved_basedir[MAXPATHLEN + 1];
134134
char local_open_basedir[MAXPATHLEN];
135-
char path_tmp[MAXPATHLEN];
135+
char path_tmp[MAXPATHLEN + 1];
136136
char *path_file;
137137
size_t resolved_basedir_len;
138138
size_t resolved_name_len;

0 commit comments

Comments
 (0)