dmitry Wed Sep 5 11:21:01 2007 UTC Modified files: /php-src/ext/soap php_soap.h soap.c /php-src/ext/soap/tests/bugs bug42214.phpt Log: Fixed bug #42214 (SoapServer sends clients internal PHP errors) http://cvs.php.net/viewvc.cgi/php-src/ext/soap/php_soap.h?r1=1.52&r2=1.53&diff_format=u Index: php-src/ext/soap/php_soap.h diff -u php-src/ext/soap/php_soap.h:1.52 php-src/ext/soap/php_soap.h:1.53 --- php-src/ext/soap/php_soap.h:1.52 Mon Apr 2 13:43:29 2007 +++ php-src/ext/soap/php_soap.h Wed Sep 5 11:21:01 2007 @@ -17,7 +17,7 @@ | Dmitry Stogov <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ -/* $Id: php_soap.h,v 1.52 2007/04/02 13:43:29 dmitry Exp $ */ +/* $Id: php_soap.h,v 1.53 2007/09/05 11:21:01 dmitry Exp $ */ #ifndef PHP_SOAP_H #define PHP_SOAP_H @@ -105,6 +105,7 @@ int type; char *actor; struct _soapHeader **soap_headers_ptr; + int send_errors; } soap_server_object; typedef struct _soap_client_object { http://cvs.php.net/viewvc.cgi/php-src/ext/soap/soap.c?r1=1.229&r2=1.230&diff_format=u Index: php-src/ext/soap/soap.c diff -u php-src/ext/soap/soap.c:1.229 php-src/ext/soap/soap.c:1.230 --- php-src/ext/soap/soap.c:1.229 Wed Sep 5 10:18:37 2007 +++ php-src/ext/soap/soap.c Wed Sep 5 11:21:01 2007 @@ -17,7 +17,7 @@ | Dmitry Stogov <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ -/* $Id: soap.c,v 1.229 2007/09/05 10:18:37 dmitry Exp $ */ +/* $Id: soap.c,v 1.230 2007/09/05 11:21:01 dmitry Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -1382,6 +1382,7 @@ } 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 @@ 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 @@ 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); http://cvs.php.net/viewvc.cgi/php-src/ext/soap/tests/bugs/bug42214.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/soap/tests/bugs/bug42214.phpt diff -u /dev/null php-src/ext/soap/tests/bugs/bug42214.phpt:1.2 --- /dev/null Wed Sep 5 11:21:01 2007 +++ php-src/ext/soap/tests/bugs/bug42214.phpt Wed Sep 5 11:21:01 2007 @@ -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>
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php