-
Notifications
You must be signed in to change notification settings - Fork 7.9k
ext/soap: Don't call readfile() userland function #17432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
51c2cf0
ext/soap: Add some SoapServer tests
Girgias 78e50f5
ext/soap: Don't call readfile() userland function
Girgias 6eb1155
ext/soap: Actually throw a SOAP Fault if the WSDL has disappeared
Girgias e101ce0
review
Girgias e6305b4
Skip tests on windows for now
Girgias d1e3520
[skip ci] Update skipif message
Girgias File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1307,19 +1307,16 @@ PHP_METHOD(SoapServer, handle) | |
sapi_add_header(hdr, sizeof("Location: ")+strlen(service->sdl->source)-1, 1); | ||
efree(hdr); | ||
*/ | ||
zval readfile, readfile_ret, param; | ||
|
||
sapi_add_header("Content-Type: text/xml; charset=utf-8", sizeof("Content-Type: text/xml; charset=utf-8")-1, 1); | ||
ZVAL_STRING(¶m, service->sdl->source); | ||
ZVAL_STRING(&readfile, "readfile"); | ||
if (call_user_function(EG(function_table), NULL, &readfile, &readfile_ret, 1, ¶m ) == FAILURE) { | ||
php_stream *stream = php_stream_open_wrapper_ex(service->sdl->source, "rb", REPORT_ERRORS, NULL, /* context */ NULL); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use the default stream context There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pleas also fix WIN64 tests failures. |
||
if (stream) { | ||
php_stream_passthru(stream); | ||
php_stream_close(stream); | ||
} else { | ||
soap_server_fault("Server", "Couldn't find WSDL", NULL, NULL, NULL); | ||
Girgias marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
zval_ptr_dtor(¶m); | ||
zval_ptr_dtor_str(&readfile); | ||
zval_ptr_dtor(&readfile_ret); | ||
|
||
SOAP_SERVER_END_CODE(); | ||
return; | ||
} else { | ||
|
80 changes: 80 additions & 0 deletions
80
ext/soap/tests/SoapServer/handle_non_existing_WSDL_from_get_query.phpt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
--TEST-- | ||
SoapServer handle with WSDL that has disappeared | ||
--EXTENSIONS-- | ||
soap | ||
--GET-- | ||
WSDL | ||
--FILE-- | ||
<?php | ||
$wsdlFile = __DIR__ . '/test_handle_non_existent_wsdl.wsdl'; | ||
Girgias marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
$wsdl = <<<'WSDL' | ||
<?xml version="1.0" ?> | ||
<definitions | ||
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" | ||
xmlns:xsd="http://www.w3.org/2001/XMLSchema" | ||
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" | ||
xmlns="http://schemas.xmlsoap.org/wsdl/"> | ||
|
||
<types> | ||
<xsd:schema targetNamespace="http://linuxsrv.home/~dmitry/soap/test.wsdl"> | ||
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" /> | ||
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" /> | ||
</xsd:schema> | ||
</types> | ||
|
||
<message name="AddRequest"> | ||
<part name="x" type="xsd:double" /> | ||
<part name="y" type="xsd:double" /> | ||
</message> | ||
<message name="AddResponse"> | ||
<part name="result" type="xsd:double" /> | ||
</message> | ||
|
||
<portType name="TestServicePortType"> | ||
<operation name="Add"> | ||
<input message="tns:AddRequest" /> | ||
<output message="tns:AddResponse" /> | ||
</operation> | ||
</portType> | ||
|
||
<binding name="TestServiceBinding" type="tns:TestServicePortType"> | ||
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" /> | ||
<operation name="Add"> | ||
<soap:operation soapAction="Add" style="rpc" /> | ||
<input> | ||
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" /> | ||
</input> | ||
<output> | ||
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" /> | ||
</output> | ||
</operation> | ||
</binding> | ||
|
||
<service name="TestService"> | ||
<port name="TestServicePort" binding="tns:TestServiceBinding"> | ||
<soap:address location="http://linuxsrv.home/~dmitry/soap/soap_server.php" /> | ||
</port> | ||
</service> | ||
|
||
</definitions> | ||
WSDL; | ||
|
||
file_put_contents($wsdlFile, $wsdl); | ||
|
||
$options = []; | ||
$server = new SoapServer($wsdlFile, $options); | ||
|
||
unlink($wsdlFile); | ||
|
||
$server->handle(); | ||
|
||
?> | ||
--CLEAN-- | ||
<?php | ||
$wsdlFile = __DIR__ . '/test_handle_non_existent_wsdl.wsdl'; | ||
@unlink($wsdlFile); | ||
?> | ||
--EXPECT-- | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Server</faultcode><faultstring>Couldn't find WSDL</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope> |
85 changes: 85 additions & 0 deletions
85
ext/soap/tests/SoapServer/handle_non_existing_WSDL_from_get_query_disable_readfile.phpt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
--TEST-- | ||
SoapServer handle with WSDL that has disappeared and disabled readfile function | ||
--EXTENSIONS-- | ||
soap | ||
--GET-- | ||
WSDL | ||
--INI-- | ||
disable_functions=readfile | ||
--FILE-- | ||
<?php | ||
$wsdlFile = __DIR__ . '/test_handle_non_existent_wsdl.wsdl'; | ||
|
||
$wsdl = <<<'WSDL' | ||
<?xml version="1.0" ?> | ||
<definitions | ||
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" | ||
xmlns:xsd="http://www.w3.org/2001/XMLSchema" | ||
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" | ||
xmlns="http://schemas.xmlsoap.org/wsdl/"> | ||
|
||
<types> | ||
<xsd:schema targetNamespace="http://linuxsrv.home/~dmitry/soap/test.wsdl"> | ||
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" /> | ||
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" /> | ||
</xsd:schema> | ||
</types> | ||
|
||
<message name="AddRequest"> | ||
<part name="x" type="xsd:double" /> | ||
<part name="y" type="xsd:double" /> | ||
</message> | ||
<message name="AddResponse"> | ||
<part name="result" type="xsd:double" /> | ||
</message> | ||
|
||
<portType name="TestServicePortType"> | ||
<operation name="Add"> | ||
<input message="tns:AddRequest" /> | ||
<output message="tns:AddResponse" /> | ||
</operation> | ||
</portType> | ||
|
||
<binding name="TestServiceBinding" type="tns:TestServicePortType"> | ||
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" /> | ||
<operation name="Add"> | ||
<soap:operation soapAction="Add" style="rpc" /> | ||
<input> | ||
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" /> | ||
</input> | ||
<output> | ||
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" /> | ||
</output> | ||
</operation> | ||
</binding> | ||
|
||
<service name="TestService"> | ||
<port name="TestServicePort" binding="tns:TestServiceBinding"> | ||
<soap:address location="http://linuxsrv.home/~dmitry/soap/soap_server.php" /> | ||
</port> | ||
</service> | ||
|
||
</definitions> | ||
WSDL; | ||
|
||
file_put_contents($wsdlFile, $wsdl); | ||
|
||
$options = []; | ||
$server = new SoapServer($wsdlFile, $options); | ||
|
||
unlink($wsdlFile); | ||
|
||
try { | ||
Girgias marked this conversation as resolved.
Show resolved
Hide resolved
|
||
$server->handle(); | ||
} catch (Throwable $e) { | ||
echo $e::class, ': ', $e->getMessage(), PHP_EOL; | ||
} | ||
?> | ||
--CLEAN-- | ||
<?php | ||
$wsdlFile = __DIR__ . '/test_handle_non_existent_wsdl.wsdl'; | ||
@unlink($wsdlFile); | ||
?> | ||
--EXPECT-- | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Server</faultcode><faultstring>Couldn't find WSDL</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope> |
89 changes: 89 additions & 0 deletions
89
ext/soap/tests/SoapServer/handle_non_existing_WSDL_from_get_query_redefine_readfile.phpt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
--TEST-- | ||
Girgias marked this conversation as resolved.
Show resolved
Hide resolved
|
||
SoapServer handle with WSDL that has disappeared and disabled and redefined readfile function | ||
--EXTENSIONS-- | ||
soap | ||
--GET-- | ||
WSDL | ||
--INI-- | ||
disable_functions=readfile | ||
--FILE-- | ||
<?php | ||
$wsdlFile = __DIR__ . '/test_handle_non_existent_wsdl.wsdl'; | ||
|
||
$wsdl = <<<'WSDL' | ||
<?xml version="1.0" ?> | ||
<definitions | ||
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" | ||
xmlns:xsd="http://www.w3.org/2001/XMLSchema" | ||
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" | ||
xmlns="http://schemas.xmlsoap.org/wsdl/"> | ||
|
||
<types> | ||
<xsd:schema targetNamespace="http://linuxsrv.home/~dmitry/soap/test.wsdl"> | ||
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" /> | ||
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" /> | ||
</xsd:schema> | ||
</types> | ||
|
||
<message name="AddRequest"> | ||
<part name="x" type="xsd:double" /> | ||
<part name="y" type="xsd:double" /> | ||
</message> | ||
<message name="AddResponse"> | ||
<part name="result" type="xsd:double" /> | ||
</message> | ||
|
||
<portType name="TestServicePortType"> | ||
<operation name="Add"> | ||
<input message="tns:AddRequest" /> | ||
<output message="tns:AddResponse" /> | ||
</operation> | ||
</portType> | ||
|
||
<binding name="TestServiceBinding" type="tns:TestServicePortType"> | ||
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" /> | ||
<operation name="Add"> | ||
<soap:operation soapAction="Add" style="rpc" /> | ||
<input> | ||
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" /> | ||
</input> | ||
<output> | ||
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" /> | ||
</output> | ||
</operation> | ||
</binding> | ||
|
||
<service name="TestService"> | ||
<port name="TestServicePort" binding="tns:TestServiceBinding"> | ||
<soap:address location="http://linuxsrv.home/~dmitry/soap/soap_server.php" /> | ||
</port> | ||
</service> | ||
|
||
</definitions> | ||
WSDL; | ||
|
||
function readfile(string $str) { | ||
throw new Exception('BOO'); | ||
} | ||
|
||
file_put_contents($wsdlFile, $wsdl); | ||
|
||
$options = []; | ||
$server = new SoapServer($wsdlFile, $options); | ||
|
||
unlink($wsdlFile); | ||
|
||
try { | ||
$server->handle(); | ||
} catch (Throwable $e) { | ||
echo $e::class, ': ', $e->getMessage(), PHP_EOL; | ||
} | ||
?> | ||
--CLEAN-- | ||
<?php | ||
$wsdlFile = __DIR__ . '/test_handle_non_existent_wsdl.wsdl'; | ||
@unlink($wsdlFile); | ||
?> | ||
--EXPECT-- | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Server</faultcode><faultstring>Couldn't find WSDL</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.