Skip to content

Commit a437eab

Browse files
committed
ext/soap: fix use of uninitialized params in do_request() on OOM bailout.
Fix #22585 close GH-22586
1 parent 3afe4e3 commit a437eab

3 files changed

Lines changed: 47 additions & 0 deletions

File tree

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ PHP NEWS
4242
. Fixed bug GH-21314 (Different session garbage collector behavior between
4343
PHP 8.3 and PHP 8.5). (jorgsowa)
4444

45+
- SOAP:
46+
. Fixed bug GH-22585 (OOM on bailout with uninitialized
47+
do_request() parameters). (David Carlier)
48+
4549
- Streams:
4650
. Fixed bug GH-21468 (Segfault in file_get_contents w/ a https URL
4751
and a proxy set). (CVE-2026-12184) (ndossche)

ext/soap/soap.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2333,6 +2333,10 @@ static bool do_request(zval *this_ptr, xmlDoc *request, const char *location, co
23332333
return false;
23342334
}
23352335

2336+
ZVAL_UNDEF(&params[0]);
2337+
ZVAL_UNDEF(&params[1]);
2338+
ZVAL_UNDEF(&params[2]);
2339+
23362340
zend_try {
23372341
ZVAL_STRINGL(&params[0], buf, buf_size);
23382342
ZVAL_STRING(&params[1], location);

ext/soap/tests/gh22585.phpt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
--TEST--
2+
GH-22585 (Use of uninitialized params in do_request() on out-of-memory bailout)
3+
--EXTENSIONS--
4+
soap
5+
--INI--
6+
soap.wsdl_cache_enabled=0
7+
memory_limit=64M
8+
--FILE--
9+
<?php
10+
/* Deep recursion that keeps issuing SOAP calls until memory is exhausted while
11+
* do_request() is only part-way through initializing its params array. The
12+
* cleanup path must not touch the uninitialized slots. Depending on the
13+
* environment the run ends either by the recursion limit (reaching "Done") or
14+
* by the memory-exhaustion fatal; both are fine, a crash/UB abort is not. */
15+
try {
16+
class MySoapClient extends SoapClient {
17+
public function __doRequest($request, $location, $action, $version, $one_way = false, ?string $uriParserClass = null): string {
18+
return '';
19+
}
20+
}
21+
22+
function main() {
23+
for (;;) {
24+
$soap = new MySoapClient(
25+
null,
26+
['location' => "http://localhost/soap.php", 'uri' => "http://localhost/"]
27+
);
28+
$soap->call(1.1);
29+
main();
30+
}
31+
}
32+
33+
main();
34+
} catch (\Throwable $e) {
35+
}
36+
echo "Done" . PHP_EOL;
37+
?>
38+
--EXPECTREGEX--
39+
(?s)(Done|.*Allowed memory size of \d+ bytes exhausted.*)

0 commit comments

Comments
 (0)