Skip to content

Commit 633fb48

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Update NEWS with info about security issues Fix GHSA-www2-q4fc-65wf Fix GHSA-h96m-rvf9-jgm2 Fix GHSA-8xr5-qppj-gvwj: PDO quoting result null deref Fix GH-20584: Information Leak of Memory
2 parents 9b33be2 + e776695 commit 633fb48

File tree

9 files changed

+140
-14
lines changed

9 files changed

+140
-14
lines changed

NEWS

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ PHP NEWS
9595
. Fixed bug GH-20329 (opcache.file_cache broken with full interned string
9696
buffer). (Arnaud)
9797

98+
- PDO:
99+
. Fixed GHSA-8xr5-qppj-gvwj (PDO quoting result null deref). (CVE-2025-14180)
100+
(Jakub Zelenka)
101+
98102
- Phar:
99103
. Fixed bug GH-20442 (Phar does not respect case-insensitiveness of
100104
__halt_compiler() when reading stub). (ndossche, TimWolla)
@@ -113,7 +117,12 @@ PHP NEWS
113117
. Fix memory leak in array_diff() with custom type checks. (ndossche)
114118
. Fixed bug GH-20583 (Stack overflow in http_build_query
115119
via deep structures). (ndossche)
116-
. Fixed bug GH-20584 (Information Leak of Memory). (ndossche)
120+
. Fixed GHSA-www2-q4fc-65wf (Null byte termination in dns_get_record()).
121+
(ndossche)
122+
. Fixed GHSA-h96m-rvf9-jgm2 (Heap buffer overflow in array_merge()).
123+
(CVE-2025-14178) (ndossche)
124+
. Fixed GHSA-3237-qqm7-mfv7 (Information Leak of Memory in getimagesize).
125+
(CVE-2025-14177) (ndossche)
117126

118127
- Streams:
119128
. Fixed bug GH-20370 (User stream filters could violate typed property

ext/pdo/pdo_sql_parser.re

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,12 @@ safe:
300300
}
301301

302302
plc->quoted = stmt->dbh->methods->quoter(stmt->dbh, buf, param_type);
303+
if (plc->quoted == NULL) {
304+
/* bork */
305+
ret = -1;
306+
strncpy(stmt->error_code, stmt->dbh->error_code, 6);
307+
goto clean_up;
308+
}
303309
}
304310
}
305311

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
#GHSA-8xr5-qppj-gvwj: NULL Pointer Derefernce for failed user input quoting
3+
--EXTENSIONS--
4+
pdo
5+
pdo_pgsql
6+
--SKIPIF--
7+
<?php
8+
require_once dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
9+
require_once dirname(__FILE__) . '/config.inc';
10+
PDOTest::skip();
11+
?>
12+
--FILE--
13+
<?php
14+
require_once dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
15+
require_once dirname(__FILE__) . '/config.inc';
16+
$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
17+
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
18+
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
19+
20+
$sql = "SELECT * FROM users where username = :username";
21+
$stmt = $db->prepare($sql);
22+
23+
$p1 = "alice\x99";
24+
var_dump($stmt->execute(['username' => $p1]));
25+
26+
?>
27+
--EXPECT--
28+
bool(false)

ext/standard/array.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4281,7 +4281,7 @@ static zend_always_inline void php_array_merge_wrapper(INTERNAL_FUNCTION_PARAMET
42814281
uint32_t argc, i;
42824282
zval *src_entry;
42834283
HashTable *src, *dest;
4284-
uint32_t count = 0;
4284+
uint64_t count = 0;
42854285

42864286
ZEND_PARSE_PARAMETERS_START(0, -1)
42874287
Z_PARAM_VARIADIC('+', args, argc)
@@ -4301,6 +4301,11 @@ static zend_always_inline void php_array_merge_wrapper(INTERNAL_FUNCTION_PARAMET
43014301
count += zend_hash_num_elements(Z_ARRVAL_P(arg));
43024302
}
43034303

4304+
if (UNEXPECTED(count >= HT_MAX_SIZE)) {
4305+
zend_throw_error(NULL, "The total number of elements must be lower than %u", HT_MAX_SIZE);
4306+
RETURN_THROWS();
4307+
}
4308+
43044309
if (argc == 2) {
43054310
zval *ret = NULL;
43064311

ext/standard/basic_functions.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ PHP_FUNCTION(inet_pton)
560560
char buffer[17];
561561

562562
ZEND_PARSE_PARAMETERS_START(1, 1)
563-
Z_PARAM_STRING(address, address_len)
563+
Z_PARAM_PATH(address, address_len)
564564
ZEND_PARSE_PARAMETERS_END();
565565

566566
memset(buffer, 0, sizeof(buffer));
@@ -592,7 +592,7 @@ PHP_FUNCTION(ip2long)
592592
struct in_addr ip;
593593

594594
ZEND_PARSE_PARAMETERS_START(1, 1)
595-
Z_PARAM_STRING(addr, addr_len)
595+
Z_PARAM_PATH(addr, addr_len)
596596
ZEND_PARSE_PARAMETERS_END();
597597

598598
if (addr_len == 0 || inet_pton(AF_INET, addr, &ip) != 1) {
@@ -2168,8 +2168,8 @@ PHP_FUNCTION(getservbyname)
21682168
struct servent *serv;
21692169

21702170
ZEND_PARSE_PARAMETERS_START(2, 2)
2171-
Z_PARAM_STR(name)
2172-
Z_PARAM_STRING(proto, proto_len)
2171+
Z_PARAM_PATH_STR(name)
2172+
Z_PARAM_PATH(proto, proto_len)
21732173
ZEND_PARSE_PARAMETERS_END();
21742174

21752175

@@ -2212,7 +2212,7 @@ PHP_FUNCTION(getservbyport)
22122212

22132213
ZEND_PARSE_PARAMETERS_START(2, 2)
22142214
Z_PARAM_LONG(port)
2215-
Z_PARAM_STRING(proto, proto_len)
2215+
Z_PARAM_PATH(proto, proto_len)
22162216
ZEND_PARSE_PARAMETERS_END();
22172217

22182218
serv = getservbyport(htons((unsigned short) port), proto);
@@ -2239,7 +2239,7 @@ PHP_FUNCTION(getprotobyname)
22392239
struct protoent *ent;
22402240

22412241
ZEND_PARSE_PARAMETERS_START(1, 1)
2242-
Z_PARAM_STRING(name, name_len)
2242+
Z_PARAM_PATH(name, name_len)
22432243
ZEND_PARSE_PARAMETERS_END();
22442244

22452245
ent = getprotobyname(name);

ext/standard/dns.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ PHP_FUNCTION(dns_check_record)
382382
#endif
383383

384384
ZEND_PARSE_PARAMETERS_START(1, 2)
385-
Z_PARAM_STRING(hostname, hostname_len)
385+
Z_PARAM_PATH(hostname, hostname_len)
386386
Z_PARAM_OPTIONAL
387387
Z_PARAM_STR(rectype)
388388
ZEND_PARSE_PARAMETERS_END();
@@ -829,7 +829,7 @@ PHP_FUNCTION(dns_get_record)
829829
bool raw = 0;
830830

831831
ZEND_PARSE_PARAMETERS_START(1, 5)
832-
Z_PARAM_STRING(hostname, hostname_len)
832+
Z_PARAM_PATH(hostname, hostname_len)
833833
Z_PARAM_OPTIONAL
834834
Z_PARAM_LONG(type_param)
835835
Z_PARAM_ZVAL(authns)
@@ -1067,7 +1067,7 @@ PHP_FUNCTION(dns_get_mx)
10671067
#endif
10681068

10691069
ZEND_PARSE_PARAMETERS_START(2, 3)
1070-
Z_PARAM_STRING(hostname, hostname_len)
1070+
Z_PARAM_PATH(hostname, hostname_len)
10711071
Z_PARAM_ZVAL(mx_list)
10721072
Z_PARAM_OPTIONAL
10731073
Z_PARAM_ZVAL(weight_list)

ext/standard/dns_win32.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ PHP_FUNCTION(dns_get_mx) /* {{{ */
4949
DNS_STATUS status; /* Return value of DnsQuery_A() function */
5050
PDNS_RECORD pResult, pRec; /* Pointer to DNS_RECORD structure */
5151

52-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sz|z", &hostname, &hostname_len, &mx_list, &weight_list) == FAILURE) {
52+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "pz|z", &hostname, &hostname_len, &mx_list, &weight_list) == FAILURE) {
5353
RETURN_THROWS();
5454
}
5555

@@ -103,7 +103,7 @@ PHP_FUNCTION(dns_check_record)
103103
DNS_STATUS status; /* Return value of DnsQuery_A() function */
104104
PDNS_RECORD pResult; /* Pointer to DNS_RECORD structure */
105105

106-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|S", &hostname, &hostname_len, &rectype) == FAILURE) {
106+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|S", &hostname, &hostname_len, &rectype) == FAILURE) {
107107
RETURN_THROWS();
108108
}
109109

@@ -360,7 +360,7 @@ PHP_FUNCTION(dns_get_record)
360360
int type, type_to_fetch, first_query = 1, store_results = 1;
361361
bool raw = 0;
362362

363-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|lz!z!b",
363+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|lz!z!b",
364364
&hostname, &hostname_len, &type_param, &authns, &addtl, &raw) == FAILURE) {
365365
RETURN_THROWS();
366366
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
GHSA-h96m-rvf9-jgm2
3+
--FILE--
4+
<?php
5+
6+
$power = 20; // Chosen to be well within a memory_limit
7+
$arr = range(0, 2**$power);
8+
try {
9+
array_merge(...array_fill(0, 2**(32-$power), $arr));
10+
} catch (Error $e) {
11+
echo $e->getMessage(), "\n";
12+
}
13+
14+
?>
15+
--EXPECTF--
16+
The total number of elements must be lower than %d
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
--TEST--
2+
GHSA-www2-q4fc-65wf
3+
--DESCRIPTION--
4+
This is a ZPP test but *keep* this as it is security-sensitive!
5+
--FILE--
6+
<?php
7+
try {
8+
dns_check_record("\0");
9+
} catch (ValueError $e) {
10+
echo $e->getMessage(), "\n";
11+
}
12+
try {
13+
dns_get_mx("\0", $out);
14+
} catch (ValueError $e) {
15+
echo $e->getMessage(), "\n";
16+
}
17+
try {
18+
dns_get_record("\0");
19+
} catch (ValueError $e) {
20+
echo $e->getMessage(), "\n";
21+
}
22+
try {
23+
getprotobyname("\0");
24+
} catch (ValueError $e) {
25+
echo $e->getMessage(), "\n";
26+
}
27+
try {
28+
getservbyname("\0", "tcp");
29+
} catch (ValueError $e) {
30+
echo $e->getMessage(), "\n";
31+
}
32+
try {
33+
getservbyname("x", "tcp\0");
34+
} catch (ValueError $e) {
35+
echo $e->getMessage(), "\n";
36+
}
37+
try {
38+
getservbyport(0, "tcp\0");
39+
} catch (ValueError $e) {
40+
echo $e->getMessage(), "\n";
41+
}
42+
try {
43+
inet_pton("\0");
44+
} catch (ValueError $e) {
45+
echo $e->getMessage(), "\n";
46+
}
47+
try {
48+
ip2long("\0");
49+
} catch (ValueError $e) {
50+
echo $e->getMessage(), "\n";
51+
}
52+
?>
53+
--EXPECT--
54+
dns_check_record(): Argument #1 ($hostname) must not contain any null bytes
55+
dns_get_mx(): Argument #1 ($hostname) must not contain any null bytes
56+
dns_get_record(): Argument #1 ($hostname) must not contain any null bytes
57+
getprotobyname(): Argument #1 ($protocol) must not contain any null bytes
58+
getservbyname(): Argument #1 ($service) must not contain any null bytes
59+
getservbyname(): Argument #2 ($protocol) must not contain any null bytes
60+
getservbyport(): Argument #2 ($protocol) must not contain any null bytes
61+
inet_pton(): Argument #1 ($ip) must not contain any null bytes
62+
ip2long(): Argument #1 ($ip) must not contain any null bytes

0 commit comments

Comments
 (0)