summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2007-09-05 11:21:01 +0000
committerDmitry Stogov <dmitry@php.net>2007-09-05 11:21:01 +0000
commit74c08d50d57a5fb9ed466873bdf730c5c76e51d9 (patch)
tree68c0ccbc272832dfb22f5565191b1dccb268c338
parent5f28a1da4e16361b6348a024c8b8b6259a5f3e3c (diff)
downloadphp-git-74c08d50d57a5fb9ed466873bdf730c5c76e51d9.tar.gz
Fixed bug #42214 (SoapServer sends clients internal PHP errors)
-rw-r--r--ext/soap/php_soap.h1
-rw-r--r--ext/soap/soap.c47
-rwxr-xr-xext/soap/tests/bugs/bug42214.phpt24
3 files changed, 57 insertions, 15 deletions
diff --git a/ext/soap/php_soap.h b/ext/soap/php_soap.h
index 9ded7d2e5a..1bd50a6bc2 100644
--- a/ext/soap/php_soap.h
+++ b/ext/soap/php_soap.h
@@ -105,6 +105,7 @@ typedef struct _soap_server_object {
int type;
char *actor;
struct _soapHeader **soap_headers_ptr;
+ int send_errors;
} soap_server_object;
typedef struct _soap_client_object {
diff --git a/ext/soap/soap.c b/ext/soap/soap.c
index ec7a230438..d7043d279f 100644
--- a/ext/soap/soap.c
+++ b/ext/soap/soap.c
@@ -1382,6 +1382,7 @@ PHP_METHOD(SoapServer, SoapServer)
}
service = (soap_server_object*)zend_object_store_get_object(this_ptr TSRMLS_CC);
+ service->send_errors = 1;
cache_wsdl = SOAP_GLOBAL(cache);
@@ -1457,6 +1458,11 @@ PHP_METHOD(SoapServer, SoapServer)
Z_TYPE_PP(tmp) == IS_LONG) {
cache_wsdl = Z_LVAL_PP(tmp);
}
+
+ if (zend_ascii_hash_find(ht, "send_errors", sizeof("send_errors"), (void**)&tmp) == SUCCESS &&
+ (Z_TYPE_PP(tmp) == IS_BOOL || Z_TYPE_PP(tmp) == IS_LONG)) {
+ service->send_errors = Z_LVAL_PP(tmp);
+ }
}
if (wsdl == NULL && service->uri == NULL) {
@@ -2504,30 +2510,41 @@ static void soap_error_handler(int error_num, const char *error_filename, const
error_num == E_PARSE) {
char* code = SOAP_GLOBAL(error_code);
+ soap_server_object *server;
char *buffer;
- int buffer_len;
zval *outbuf = NULL;
- zval outbuflen;
- INIT_ZVAL(outbuflen);
+ if (code == NULL) {
+ code = "Server";
+ }
+
+ if (SOAP_GLOBAL(error_object) &&
+ Z_TYPE_P(SOAP_GLOBAL(error_object)) == IS_OBJECT &&
+ instanceof_function(Z_OBJCE_P(SOAP_GLOBAL(error_object)), soap_server_class_entry TSRMLS_CC) &&
+ (server = (soap_server_object*)zend_object_store_get_object(SOAP_GLOBAL(error_object) TSRMLS_CC)) &&
+ !server->send_errors) {
+ buffer = estrdup("Internal Error");
+ } else {
+ int buffer_len;
+ zval outbuflen;
+
+ INIT_ZVAL(outbuflen);
#ifdef va_copy
- va_copy(argcopy, args);
- buffer_len = vspprintf(&buffer, 0, format, argcopy);
- va_end(argcopy);
+ va_copy(argcopy, args);
+ buffer_len = vspprintf(&buffer, 0, format, argcopy);
+ va_end(argcopy);
#else
- buffer_len = vspprintf(&buffer, 0, format, args);
+ buffer_len = vspprintf(&buffer, 0, format, args);
#endif
- if (code == NULL) {
- code = "Server";
- }
- /* Get output buffer and send as fault detials */
- if (php_output_get_length(&outbuflen TSRMLS_CC) != FAILURE && Z_LVAL(outbuflen) != 0) {
- ALLOC_INIT_ZVAL(outbuf);
- php_output_get_contents(outbuf TSRMLS_CC);
+ /* Get output buffer and send as fault detials */
+ if (php_output_get_length(&outbuflen TSRMLS_CC) != FAILURE && Z_LVAL(outbuflen) != 0) {
+ ALLOC_INIT_ZVAL(outbuf);
+ php_output_get_contents(outbuf TSRMLS_CC);
+ }
+ php_output_discard(TSRMLS_C);
}
- php_output_discard(TSRMLS_C);
INIT_ZVAL(fault_obj);
set_soap_fault(&fault_obj, NULL, code, buffer, NULL, outbuf, NULL TSRMLS_CC);
diff --git a/ext/soap/tests/bugs/bug42214.phpt b/ext/soap/tests/bugs/bug42214.phpt
new file mode 100755
index 0000000000..2f85686842
--- /dev/null
+++ b/ext/soap/tests/bugs/bug42214.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Bug #42214 SoapServer sends clients internal PHP errors
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$request = <<<EOF
+<?xml version="1.0" encoding="UTF-8"?>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://localhost/server.php" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:test/></SOAP-ENV:Body></SOAP-ENV:Envelope>
+EOF;
+
+function test() {
+ $a = $b;
+ obvious_error(); // will cause an error
+}
+
+$server = new SoapServer(NULL, array('uri' =>'http://localhost/server.php',
+ 'send_errors'=>0));
+$server->addFunction('test');
+$server->handle($request);
+?>
+--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>Internal Error</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>