From: Dmitry Stogov Date: Wed, 2 Feb 2005 09:11:03 +0000 (+0000) Subject: Fixed bug #31755 (Cannot create SOAP header in no namespace) X-Git-Tag: php-5.0.4RC1~213 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4f45d300fb82f61ebafd669a842bda03c16e7a64;p=php Fixed bug #31755 (Cannot create SOAP header in no namespace) --- diff --git a/NEWS b/NEWS index 1196f9092a..278498aec7 100644 --- a/NEWS +++ b/NEWS @@ -16,6 +16,7 @@ PHP NEWS - Fixed posix_getsid() & posix_getpgid() to return sid & pgid instead of true. (Tony) - Fixed bug #31797 (exif_read_data() uses too low nesting limit). (Ilia) +- Fixed bug #31755 (Cannot create SOAP header in no namespace). (Dmitry) - Fixed bug #31732 (mb_get_info() causes segfault when no parameters specified). (Tony) - Fixed bug #31710 (Wrong return values for mysqli_autocommit/commit/rollback). diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c index 4b9a97258d..57983a0529 100644 --- a/ext/soap/php_http.c +++ b/ext/soap/php_http.c @@ -655,6 +655,7 @@ try_again: } if (!get_http_headers(stream, &http_headers, &http_header_size TSRMLS_CC)) { + efree(http_headers); if (request != buf) {efree(request);} php_stream_close(stream); zend_hash_del(Z_OBJPROP_P(this_ptr), "httpsocket", sizeof("httpsocket")); @@ -690,6 +691,7 @@ try_again: if (http_status == 100) { efree(http_headers); if (!get_http_headers(stream, &http_headers, &http_header_size TSRMLS_CC)) { + efree(http_headers); if (request != buf) {efree(request);} php_stream_close(stream); zend_hash_del(Z_OBJPROP_P(this_ptr), "httpsocket", sizeof("httpsocket")); diff --git a/ext/soap/soap.c b/ext/soap/soap.c index 7814f79bb4..b76773d449 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -656,6 +656,9 @@ PHP_METHOD(SoapParam, SoapParam) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zs", &data, &name, &name_length) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters"); } + if (name_length == 0) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters. Invalid parameter name."); + } #ifndef ZEND_ENGINE_2 zval_add_ref(&data); @@ -678,6 +681,12 @@ PHP_METHOD(SoapHeader, SoapHeader) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|zbz", &ns, &ns_len, &name, &name_len, &data, &must_understand, &actor) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters"); } + if (ns_len == 0) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters. Invalid namespace."); + } + if (name_len == 0) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters. Invalid header name."); + } add_property_stringl(this_ptr, "namespace", ns, ns_len, 1); add_property_stringl(this_ptr, "name", name, name_len, 1); @@ -689,12 +698,15 @@ PHP_METHOD(SoapHeader, SoapHeader) } add_property_bool(this_ptr, "mustUnderstand", must_understand); if (actor == NULL) { - } else if (Z_TYPE_P(actor) == IS_LONG) { + } else if (Z_TYPE_P(actor) == IS_LONG && + (Z_LVAL_P(actor) == SOAP_ACTOR_NEXT || + Z_LVAL_P(actor) == SOAP_ACTOR_NONE || + Z_LVAL_P(actor) == SOAP_ACTOR_UNLIMATERECEIVER)) { add_property_long(this_ptr, "actor", Z_LVAL_P(actor)); - } else if (Z_TYPE_P(actor) == IS_STRING) { + } else if (Z_TYPE_P(actor) == IS_STRING && Z_STRLEN_P(actor) > 0) { add_property_stringl(this_ptr, "actor", Z_STRVAL_P(actor), Z_STRLEN_P(actor), 1); } else { - php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters"); + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters. Invalid actor."); } } @@ -713,6 +725,12 @@ PHP_METHOD(SoapFault, SoapFault) &details, &name, &name_len, &headerfault) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters"); } + if (fault_code != NULL && fault_code_len == 0) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters. Invalid fault code."); + } + if (name != NULL && name_len == 0) { + name = NULL; + } set_soap_fault(this_ptr, fault_code, fault_string, fault_actor, details, name TSRMLS_CC); if (headerfault != NULL) { @@ -792,16 +810,16 @@ PHP_METHOD(SoapVar, SoapVar) add_property_zval(this_ptr, "enc_value", data); } - if (stype && strlen(stype) > 0) { + if (stype && stype_len > 0) { add_property_stringl(this_ptr, "enc_stype", stype, stype_len, 1); } - if (ns && strlen(ns) > 0) { + if (ns && ns_len > 0) { add_property_stringl(this_ptr, "enc_ns", ns, ns_len, 1); } - if (name && strlen(name) > 0) { + if (name && name_len > 0) { add_property_stringl(this_ptr, "enc_name", name, name_len, 1); } - if (namens && strlen(namens) > 0) { + if (namens && namens_len > 0) { add_property_stringl(this_ptr, "enc_namens", namens, namens_len, 1); } } diff --git a/ext/soap/tests/bugs/bug31755.phpt b/ext/soap/tests/bugs/bug31755.phpt new file mode 100644 index 0000000000..e93e17daa6 --- /dev/null +++ b/ext/soap/tests/bugs/bug31755.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #31422 No Error-Logging on SoapServer-Side +--SKIPIF-- + +--FILE-- + 'http://localhost', +'uri' => 'myNS', 'exceptions' => false, 'trace' => true)); + +$header = new SOAPHeader(null, 'foo', 'bar'); + +$response= $client->__call('function', array(), null, $header); + +print $client->__getLastRequest(); +?> +--EXPECTF-- +Fatal error: SoapHeader::__construct(): Invalid parameters. Invalid namespace. in %sbug31755.php on line %d