Skip to content

Commit 80d580b

Browse files
committed
Fix phpGH-22218: SoapServer::handle() crash on non-array $_SERVER.
Move the HTTP_SOAPACTION lookup inside the existing $_SERVER NULL/array guard; it dereferenced server_vars unconditionally, crashing when $_SERVER was unset or a scalar. Fix php#22218 close GHH-22220
1 parent 092fd61 commit 80d580b

3 files changed

Lines changed: 32 additions & 3 deletions

File tree

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ PHP NEWS
1616
Phar::addEmptyDir() for paths starting with "/.phar", while allowing
1717
non-magic directory names that merely share the ".phar" prefix. (Weilin Du)
1818

19+
- SOAP:
20+
. Fixed bug GH-22218 (SoapServer::handle() crash on $_SERVER not being
21+
an array). (David Carlier / Rex-Reynolds)
22+
1923
- Zlib:
2024
. Fixed memory leak if deflate initialization fails and there is a dict.
2125
(ndossche)

ext/soap/soap.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,10 +1393,10 @@ PHP_METHOD(SoapServer, handle)
13931393
return;
13941394
}
13951395
}
1396-
}
13971396

1398-
if ((soap_action_z = zend_hash_str_find(Z_ARRVAL_P(server_vars), ZEND_STRL("HTTP_SOAPACTION"))) != NULL && Z_TYPE_P(soap_action_z) == IS_STRING) {
1399-
soap_action = Z_STRVAL_P(soap_action_z);
1397+
if ((soap_action_z = zend_hash_str_find(Z_ARRVAL_P(server_vars), ZEND_STRL("HTTP_SOAPACTION"))) != NULL && Z_TYPE_P(soap_action_z) == IS_STRING) {
1398+
soap_action = Z_STRVAL_P(soap_action_z);
1399+
}
14001400
}
14011401

14021402
doc_request = soap_xmlParseFile("php://input");

ext/soap/tests/gh22218.phpt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
GH-22218 (SoapServer::handle() segfault on non-array/unset $_SERVER)
3+
--EXTENSIONS--
4+
soap
5+
--CREDITS--
6+
Rex-Reynolds
7+
--SKIPIF--
8+
<?php
9+
if (php_sapi_name() == 'cli') echo 'skip needs request body (POST)';
10+
?>
11+
--POST--
12+
<SOAP-ENV:Envelope
13+
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
14+
<SOAP-ENV:Body>
15+
<test/>
16+
</SOAP-ENV:Body>
17+
</SOAP-ENV:Envelope>
18+
--FILE--
19+
<?php
20+
$_SERVER = 79;
21+
$server = new SoapServer(null, ['uri' => 'http://test-uri']);
22+
$server->handle();
23+
?>
24+
--EXPECTF--
25+
%AFunction 'test' doesn't exist%A

0 commit comments

Comments
 (0)