]> granicus.if.org Git - php/commitdiff
Fixed bug #31755 (Cannot create SOAP header in no namespace)
authorDmitry Stogov <dmitry@php.net>
Wed, 2 Feb 2005 09:11:03 +0000 (09:11 +0000)
committerDmitry Stogov <dmitry@php.net>
Wed, 2 Feb 2005 09:11:03 +0000 (09:11 +0000)
NEWS
ext/soap/php_http.c
ext/soap/soap.c
ext/soap/tests/bugs/bug31755.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 1196f9092a6e5886a61fa884c83b6e5b54ed8517..278498aec70ad00ef9d08b912b919e37280cf20e 100644 (file)
--- 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).
index 4b9a97258db08ec841f07e737bfb8aaa842da65e..57983a0529ec8d97533b734c8d8b0c01af8bd5f7 100644 (file)
@@ -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"));
index 7814f79bb4d59d7ceff510d1dbee61c55d487947..b76773d449311ed84cf595c8f8f7e60964665e0a 100644 (file)
@@ -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 (file)
index 0000000..e93e17d
--- /dev/null
@@ -0,0 +1,17 @@
+--TEST--
+Bug #31422 No Error-Logging on SoapServer-Side
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$client=new SOAPClient(null, array('location' => '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