Skip to content

Commit 78e50f5

Browse files
committed
ext/soap: Don't call readfile() userland function
We can perform the operation directly, moreover there is no risk of a user disabling the readfile function and defining their own messing up what we are doing.
1 parent 51c2cf0 commit 78e50f5

3 files changed

+4
-11
lines changed

ext/soap/soap.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,19 +1307,14 @@ PHP_METHOD(SoapServer, handle)
13071307
sapi_add_header(hdr, sizeof("Location: ")+strlen(service->sdl->source)-1, 1);
13081308
efree(hdr);
13091309
*/
1310-
zval readfile, readfile_ret, param;
13111310

13121311
sapi_add_header("Content-Type: text/xml; charset=utf-8", sizeof("Content-Type: text/xml; charset=utf-8")-1, 1);
1313-
ZVAL_STRING(&param, service->sdl->source);
1314-
ZVAL_STRING(&readfile, "readfile");
1315-
if (call_user_function(EG(function_table), NULL, &readfile, &readfile_ret, 1, &param ) == FAILURE) {
1316-
soap_server_fault("Server", "Couldn't find WSDL", NULL, NULL, NULL);
1312+
php_stream *stream = php_stream_open_wrapper_ex(service->sdl->source, "rb", REPORT_ERRORS, NULL, /* context */ NULL);
1313+
if (stream) {
1314+
php_stream_passthru(stream);
1315+
php_stream_close(stream);
13171316
}
13181317

1319-
zval_ptr_dtor(&param);
1320-
zval_ptr_dtor_str(&readfile);
1321-
zval_ptr_dtor(&readfile_ret);
1322-
13231318
SOAP_SERVER_END_CODE();
13241319
return;
13251320
} else {

ext/soap/tests/SoapServer/handle_non_existing_WSDL_from_get_query_disable_readfile.phpt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,3 @@ $wsdlFile = __DIR__ . '/test_handle_non_existent_wsdl.wsdl';
8181
@unlink($wsdlFile);
8282
?>
8383
--EXPECT--
84-
Error: Invalid callback readfile, function "readfile" not found or invalid function name

ext/soap/tests/SoapServer/handle_non_existing_WSDL_from_get_query_redefine_readfile.phpt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,3 @@ $wsdlFile = __DIR__ . '/test_handle_non_existent_wsdl.wsdl';
8585
@unlink($wsdlFile);
8686
?>
8787
--EXPECT--
88-
Exception: BOO

0 commit comments

Comments
 (0)