diff options
Diffstat (limited to 'ext/soap')
-rw-r--r-- | ext/soap/php_encoding.c | 38 | ||||
-rw-r--r-- | ext/soap/soap.c | 44 | ||||
-rw-r--r-- | ext/soap/tests/bug48557.phpt | 2 | ||||
-rw-r--r-- | ext/soap/tests/bugs/bug28751.phpt | 4 | ||||
-rw-r--r-- | ext/soap/tests/bugs/bug29844.phpt | 2 | ||||
-rw-r--r-- | ext/soap/tests/fault_warning.phpt | 28 |
6 files changed, 58 insertions, 60 deletions
diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c index d5461f80d0..a88d14fb1a 100644 --- a/ext/soap/php_encoding.c +++ b/ext/soap/php_encoding.c @@ -283,16 +283,6 @@ static encodePtr find_encoder_by_type_name(sdlPtr sdl, const char *type) return NULL; } -static zval *soap_hash_str_find_deref(HashTable *ht, const char *str, size_t len) { - zval *zv = zend_hash_str_find(ht, str, len); - if (!zv) { - return NULL; - } - - ZVAL_DEREF(zv); - return zv; -} - static zend_bool soap_check_zval_ref(zval *data, xmlNodePtr node) { xmlNodePtr node_ptr; @@ -402,14 +392,14 @@ static xmlNodePtr master_to_xml_int(encodePtr encode, zval *data, int style, xml encodePtr enc = NULL; HashTable *ht = Z_OBJPROP_P(data); - if ((ztype = soap_hash_str_find_deref(ht, "enc_type", sizeof("enc_type")-1)) == NULL || + if ((ztype = zend_hash_str_find_deref(ht, "enc_type", sizeof("enc_type")-1)) == NULL || Z_TYPE_P(ztype) != IS_LONG) { soap_error0(E_ERROR, "Encoding: SoapVar has no 'enc_type' property"); } - if ((zstype = soap_hash_str_find_deref(ht, "enc_stype", sizeof("enc_stype")-1)) != NULL && + if ((zstype = zend_hash_str_find_deref(ht, "enc_stype", sizeof("enc_stype")-1)) != NULL && Z_TYPE_P(zstype) == IS_STRING) { - if ((zns = soap_hash_str_find_deref(ht, "enc_ns", sizeof("enc_ns")-1)) != NULL && + if ((zns = zend_hash_str_find_deref(ht, "enc_ns", sizeof("enc_ns")-1)) != NULL && Z_TYPE_P(zns) == IS_STRING) { enc = get_encoder(SOAP_GLOBAL(sdl), Z_STRVAL_P(zns), Z_STRVAL_P(zstype)); } else { @@ -436,13 +426,13 @@ static xmlNodePtr master_to_xml_int(encodePtr encode, zval *data, int style, xml enc = encode; } - zdata = soap_hash_str_find_deref(ht, "enc_value", sizeof("enc_value")-1); + zdata = zend_hash_str_find_deref(ht, "enc_value", sizeof("enc_value")-1); node = master_to_xml(enc, zdata, style, parent); if (style == SOAP_ENCODED || (SOAP_GLOBAL(sdl) && encode != enc)) { - if ((zstype = soap_hash_str_find_deref(ht, "enc_stype", sizeof("enc_stype")-1)) != NULL && + if ((zstype = zend_hash_str_find_deref(ht, "enc_stype", sizeof("enc_stype")-1)) != NULL && Z_TYPE_P(zstype) == IS_STRING) { - if ((zns = soap_hash_str_find_deref(ht, "enc_ns", sizeof("enc_ns")-1)) != NULL && + if ((zns = zend_hash_str_find_deref(ht, "enc_ns", sizeof("enc_ns")-1)) != NULL && Z_TYPE_P(zns) == IS_STRING) { set_ns_and_type_ex(node, Z_STRVAL_P(zns), Z_STRVAL_P(zstype)); } else { @@ -451,11 +441,11 @@ static xmlNodePtr master_to_xml_int(encodePtr encode, zval *data, int style, xml } } - if ((zname = soap_hash_str_find_deref(ht, "enc_name", sizeof("enc_name")-1)) != NULL && + if ((zname = zend_hash_str_find_deref(ht, "enc_name", sizeof("enc_name")-1)) != NULL && Z_TYPE_P(zname) == IS_STRING) { xmlNodeSetName(node, BAD_CAST(Z_STRVAL_P(zname))); } - if ((znamens = soap_hash_str_find_deref(ht, "enc_namens", sizeof("enc_namens")-1)) != NULL && + if ((znamens = zend_hash_str_find_deref(ht, "enc_namens", sizeof("enc_namens")-1)) != NULL && Z_TYPE_P(znamens) == IS_STRING) { xmlNsPtr nsp = encode_add_ns(node, Z_STRVAL_P(znamens)); xmlSetNs(node, nsp); @@ -1214,7 +1204,7 @@ static zval* get_zval_property(zval* object, char* name, zval *rv) ZVAL_DEREF(data); return data; } else if (Z_TYPE_P(object) == IS_ARRAY) { - return soap_hash_str_find_deref(Z_ARRVAL_P(object), name, strlen(name)); + return zend_hash_str_find_deref(Z_ARRVAL_P(object), name, strlen(name)); } return NULL; } @@ -1429,7 +1419,7 @@ static zval *to_zval_object_ex(zval *ret, encodeTypePtr type, xmlNodePtr data, z zval *classname; zend_class_entry *tmp; - if ((classname = soap_hash_str_find_deref(SOAP_GLOBAL(class_map), type->type_str, strlen(type->type_str))) != NULL && + if ((classname = zend_hash_str_find_deref(SOAP_GLOBAL(class_map), type->type_str, strlen(type->type_str))) != NULL && Z_TYPE_P(classname) == IS_STRING && (tmp = zend_fetch_class(Z_STR_P(classname), ZEND_FETCH_CLASS_AUTO)) != NULL) { ce = tmp; @@ -2912,7 +2902,7 @@ static xmlNodePtr to_xml_datetime_ex(encodeTypePtr type, zval *data, char *forma #ifdef HAVE_TM_GMTOFF snprintf(tzbuf, sizeof(tzbuf), "%c%02d:%02d", (ta->tm_gmtoff < 0) ? '-' : '+', abs(ta->tm_gmtoff / 3600), abs( (ta->tm_gmtoff % 3600) / 60 )); #else -# if defined(__CYGWIN__) || defined(NETWARE) || (defined(PHP_WIN32) && defined(_MSC_VER) && _MSC_VER >= 1900) +# if defined(__CYGWIN__) || (defined(PHP_WIN32) && defined(_MSC_VER) && _MSC_VER >= 1900) snprintf(tzbuf, sizeof(tzbuf), "%c%02d:%02d", ((ta->tm_isdst ? _timezone - 3600:_timezone)>0)?'-':'+', abs((ta->tm_isdst ? _timezone - 3600 : _timezone) / 3600), abs(((ta->tm_isdst ? _timezone - 3600 : _timezone) % 3600) / 60)); # else snprintf(tzbuf, sizeof(tzbuf), "%c%02d:%02d", ((ta->tm_isdst ? timezone - 3600:timezone)>0)?'-':'+', abs((ta->tm_isdst ? timezone - 3600 : timezone) / 3600), abs(((ta->tm_isdst ? timezone - 3600 : timezone) % 3600) / 60)); @@ -3535,20 +3525,20 @@ static encodePtr get_array_type(xmlNodePtr node, zval *array, smart_str *type) Z_OBJCE_P(tmp) == soap_var_class_entry) { zval *ztype; - if ((ztype = soap_hash_str_find_deref(Z_OBJPROP_P(tmp), "enc_type", sizeof("enc_type")-1)) == NULL || + if ((ztype = zend_hash_str_find_deref(Z_OBJPROP_P(tmp), "enc_type", sizeof("enc_type")-1)) == NULL || Z_TYPE_P(ztype) != IS_LONG) { soap_error0(E_ERROR, "Encoding: SoapVar has no 'enc_type' property"); } cur_type = Z_LVAL_P(ztype); - if ((ztype = soap_hash_str_find_deref(Z_OBJPROP_P(tmp), "enc_stype", sizeof("enc_stype")-1)) != NULL && + if ((ztype = zend_hash_str_find_deref(Z_OBJPROP_P(tmp), "enc_stype", sizeof("enc_stype")-1)) != NULL && Z_TYPE_P(ztype) == IS_STRING) { cur_stype = Z_STRVAL_P(ztype); } else { cur_stype = NULL; } - if ((ztype = soap_hash_str_find_deref(Z_OBJPROP_P(tmp), "enc_ns", sizeof("enc_ns")-1)) != NULL && + if ((ztype = zend_hash_str_find_deref(Z_OBJPROP_P(tmp), "enc_ns", sizeof("enc_ns")-1)) != NULL && Z_TYPE_P(ztype) == IS_STRING) { cur_ns = Z_STRVAL_P(ztype); } else { diff --git a/ext/soap/soap.c b/ext/soap/soap.c index c2b84746b2..4835857f3d 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -69,7 +69,7 @@ static void delete_service(void *service); static void delete_url(void *handle); static void delete_hashtable(void *hashtable); -static void soap_error_handler(int error_num, const char *error_filename, const uint error_lineno, const char *format, va_list args); +static void soap_error_handler(int error_num, const char *error_filename, const uint32_t error_lineno, const char *format, va_list args); #define SOAP_SERVER_BEGIN_CODE() \ zend_bool _old_handler = SOAP_GLOBAL(use_soap_error_handler);\ @@ -165,9 +165,8 @@ zend_class_entry* soap_var_class_entry; ZEND_DECLARE_MODULE_GLOBALS(soap) -static void (*old_error_handler)(int, const char *, const uint, const char*, va_list); +static void (*old_error_handler)(int, const char *, const uint32_t, const char*, va_list); -#ifdef va_copy #define call_old_error_handler(error_num, error_filename, error_lineno, format, args) \ { \ va_list copy; \ @@ -175,12 +174,6 @@ static void (*old_error_handler)(int, const char *, const uint, const char*, va_ old_error_handler(error_num, error_filename, error_lineno, format, copy); \ va_end(copy); \ } -#else -#define call_old_error_handler(error_num, error_filename, error_lineno, format, args) \ -{ \ - old_error_handler(error_num, error_filename, error_lineno, format, args); \ -} -#endif #define PHP_SOAP_SERVER_CLASSNAME "SoapServer" #define PHP_SOAP_CLIENT_CLASSNAME "SoapClient" @@ -898,16 +891,12 @@ PHP_METHOD(SoapFault, SoapFault) fault_code = Z_STRVAL_P(code); fault_code_len = Z_STRLEN_P(code); } else if (Z_TYPE_P(code) == IS_ARRAY && zend_hash_num_elements(Z_ARRVAL_P(code)) == 2) { - zval *t_ns, *t_code; - - zend_hash_internal_pointer_reset(Z_ARRVAL_P(code)); - t_ns = zend_hash_get_current_data(Z_ARRVAL_P(code)); - zend_hash_move_forward(Z_ARRVAL_P(code)); - t_code = zend_hash_get_current_data(Z_ARRVAL_P(code)); - if (Z_TYPE_P(t_ns) == IS_STRING && Z_TYPE_P(t_code) == IS_STRING) { - fault_code_ns = Z_STRVAL_P(t_ns); - fault_code = Z_STRVAL_P(t_code); - fault_code_len = Z_STRLEN_P(t_code); + zval *t_ns = zend_hash_index_find(Z_ARRVAL_P(code), 0); + zval *t_code = zend_hash_index_find(Z_ARRVAL_P(code), 1); + if (t_ns && t_code && Z_TYPE_P(t_ns) == IS_STRING && Z_TYPE_P(t_code) == IS_STRING) { + fault_code_ns = Z_STRVAL_P(t_ns); + fault_code = Z_STRVAL_P(t_code); + fault_code_len = Z_STRLEN_P(t_code); } else { php_error_docref(NULL, E_WARNING, "Invalid fault code"); return; @@ -2126,7 +2115,7 @@ static void soap_server_fault(char* code, char* string, char *actor, zval* detai zend_bailout(); } -static void soap_error_handler(int error_num, const char *error_filename, const uint error_lineno, const char *format, va_list args) +static void soap_error_handler(int error_num, const char *error_filename, const uint32_t error_lineno, const char *format, va_list args) { zend_bool _old_in_compilation; zend_execute_data *_old_current_execute_data; @@ -2163,17 +2152,12 @@ static void soap_error_handler(int error_num, const char *error_filename, const char* code = SOAP_GLOBAL(error_code); char buffer[1024]; size_t buffer_len; -#ifdef va_copy va_list argcopy; -#endif -#ifdef va_copy va_copy(argcopy, args); buffer_len = vslprintf(buffer, sizeof(buffer)-1, format, argcopy); va_end(argcopy); -#else - buffer_len = vslprintf(buffer, sizeof(buffer)-1, format, args); -#endif + buffer[sizeof(buffer)-1]=0; if (buffer_len > sizeof(buffer) - 1 || buffer_len == (size_t)-1) { buffer_len = sizeof(buffer) - 1; @@ -2196,9 +2180,7 @@ static void soap_error_handler(int error_num, const char *error_filename, const int old = PG(display_errors); int fault = 0; zval fault_obj; -#ifdef va_copy va_list argcopy; -#endif if (error_num == E_USER_ERROR || error_num == E_COMPILE_ERROR || @@ -2226,13 +2208,10 @@ static void soap_error_handler(int error_num, const char *error_filename, const size_t buffer_len; zval outbuflen; -#ifdef va_copy va_copy(argcopy, args); buffer_len = vslprintf(buffer, sizeof(buffer)-1, format, argcopy); va_end(argcopy); -#else - buffer_len = vslprintf(buffer, sizeof(buffer)-1, format, args); -#endif + buffer[sizeof(buffer)-1]=0; if (buffer_len > sizeof(buffer) - 1 || buffer_len == (size_t)-1) { buffer_len = sizeof(buffer) - 1; @@ -2932,6 +2911,7 @@ PHP_METHOD(SoapClient, __call) } ZEND_HASH_FOREACH_END(); } if (output_headers) { + zval_ptr_dtor(output_headers); array_init(output_headers); } do_soap_call(execute_data, this_ptr, function, function_len, arg_count, real_args, return_value, location, soap_action, uri, soap_headers, output_headers); diff --git a/ext/soap/tests/bug48557.phpt b/ext/soap/tests/bug48557.phpt index 07245793db..e98c6d13b9 100644 --- a/ext/soap/tests/bug48557.phpt +++ b/ext/soap/tests/bug48557.phpt @@ -64,7 +64,7 @@ array(6) { float(123.5) [-2000]=> float(123.5) - [%u|b%"011"]=> + ["011"]=> float(123.5) [12]=> float(123.5) diff --git a/ext/soap/tests/bugs/bug28751.phpt b/ext/soap/tests/bugs/bug28751.phpt index 697ebd882a..88187eb109 100644 --- a/ext/soap/tests/bugs/bug28751.phpt +++ b/ext/soap/tests/bugs/bug28751.phpt @@ -4,13 +4,13 @@ Bug #28751 (SoapServer does not call _autoload()) <?php require_once('skipif.inc'); ?> --FILE-- <?php -function __autoload($className) { +spl_autoload_register(function ($className) { class SoapServerActions { function test() { return "Hello World"; } } -} +}); $server = new SoapServer(NULL, array('uri'=>"http://testuri.org")); $server->setClass("SoapServerActions"); diff --git a/ext/soap/tests/bugs/bug29844.phpt b/ext/soap/tests/bugs/bug29844.phpt index efaccbc31a..a3006639b1 100644 --- a/ext/soap/tests/bugs/bug29844.phpt +++ b/ext/soap/tests/bugs/bug29844.phpt @@ -18,7 +18,7 @@ class LocalSoapClient extends SoapClient { function __construct($wsdl, $options) { parent::__construct($wsdl, $options); $this->server = new SoapServer($wsdl, $options); - $this->server->setClass('hello_world');; + $this->server->setClass('hello_world'); } function __doRequest($request, $location, $action, $version, $one_way = 0) { diff --git a/ext/soap/tests/fault_warning.phpt b/ext/soap/tests/fault_warning.phpt new file mode 100644 index 0000000000..98d2d269ea --- /dev/null +++ b/ext/soap/tests/fault_warning.phpt @@ -0,0 +1,28 @@ +--TEST-- +SoapFault class: Invalid Fault code warning given? Can't be an empty string, an array of not 2 elements etc. +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +$fault = new SoapFault("", "message"); // Can't be an empty string +$fault = new SoapFault(0, "message"); // Can't be a non-string (except for null) +$fault = new SoapFault("Sender", "message"); +echo get_class($fault) . "\n"; +$fault = new SoapFault(null, "message"); +echo get_class($fault) . "\n"; +$fault = new SoapFault(["more"], "message"); // two elements in array required +$fault = new SoapFault(["m", "more", "superflous"], "message"); // two required +$fault = new SoapFault(["more-ns", "Sender"], "message"); // two given +echo get_class($fault); +?> +--EXPECTF-- +Warning: SoapFault::SoapFault(): Invalid fault code in %s on line %d + +Warning: SoapFault::SoapFault(): Invalid fault code in %s on line %d +SoapFault +SoapFault + +Warning: SoapFault::SoapFault(): Invalid fault code in %s on line %d + +Warning: SoapFault::SoapFault(): Invalid fault code in %s on line %d +SoapFault |