From 94527816f4b4b50f31d7fb8ddb30e4a88065aa6e Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 18 Dec 2006 14:39:39 +0000 Subject: [PATCH] Fixed bug #39832 (SOAP Server: parameter not matching the WSDL specified type are set to 0) --- ext/soap/php_encoding.c | 45 +++++++++++++++++++++---- ext/soap/tests/bugs/bug39832.phpt | 29 ++++++++++++++++ ext/soap/tests/bugs/bug39832.wsdl | 55 +++++++++++++++++++++++++++++++ 3 files changed, 122 insertions(+), 7 deletions(-) create mode 100755 ext/soap/tests/bugs/bug39832.phpt create mode 100755 ext/soap/tests/bugs/bug39832.wsdl diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c index e7c32c4293..f689d333a2 100644 --- a/ext/soap/php_encoding.c +++ b/ext/soap/php_encoding.c @@ -666,9 +666,15 @@ static zval *to_zval_base64(encodeTypePtr type, xmlNodePtr data) if (data->children->type == XML_TEXT_NODE && data->children->next == NULL) { whiteSpace_collapse(data->children->content); str = (char*)php_base64_decode(data->children->content, strlen((char*)data->children->content), &str_len); + if (!str) { + soap_error0(E_ERROR, "Encoding: Violation of encoding rules"); + } ZVAL_STRINGL(ret, str, str_len, 0); } else if (data->children->type == XML_CDATA_SECTION_NODE && data->children->next == NULL) { str = (char*)php_base64_decode(data->children->content, strlen((char*)data->children->content), &str_len); + if (!str) { + soap_error0(E_ERROR, "Encoding: Violation of encoding rules"); + } ZVAL_STRINGL(ret, str, str_len, 0); } else { soap_error0(E_ERROR, "Encoding: Violation of encoding rules"); @@ -705,6 +711,8 @@ static zval *to_zval_hexbin(encodeTypePtr type, xmlNodePtr data) str[i] = (c - 'a' + 10) << 4; } else if (c >= 'A' && c <= 'F') { str[i] = (c - 'A' + 10) << 4; + } else { + soap_error0(E_ERROR, "Encoding: Violation of encoding rules"); } c = data->children->content[j++]; if (c >= '0' && c <= '9') { @@ -713,6 +721,8 @@ static zval *to_zval_hexbin(encodeTypePtr type, xmlNodePtr data) str[i] |= c - 'a' + 10; } else if (c >= 'A' && c <= 'F') { str[i] |= c - 'A' + 10; + } else { + soap_error0(E_ERROR, "Encoding: Violation of encoding rules"); } } str[str_len] = '\0'; @@ -825,8 +835,22 @@ static zval *to_zval_double(encodeTypePtr type, xmlNodePtr data) if (data && data->children) { if (data->children->type == XML_TEXT_NODE && data->children->next == NULL) { + long lval; + double dval; + whiteSpace_collapse(data->children->content); - ZVAL_DOUBLE(ret, atof((char*)data->children->content)); + switch (is_numeric_string((char*)data->children->content, strlen((char*)data->children->content), &lval, &dval, 0)) { + case IS_LONG: + Z_TYPE_P(ret) = IS_DOUBLE; + Z_DVAL_P(ret) = lval; + break; + case IS_DOUBLE: + Z_TYPE_P(ret) = IS_DOUBLE; + Z_DVAL_P(ret) = dval; + break; + default: + soap_error0(E_ERROR, "Encoding: Violation of encoding rules"); + } } else { soap_error0(E_ERROR, "Encoding: Violation of encoding rules"); } @@ -844,14 +868,21 @@ static zval *to_zval_long(encodeTypePtr type, xmlNodePtr data) if (data && data->children) { if (data->children->type == XML_TEXT_NODE && data->children->next == NULL) { + long lval; + double dval; + whiteSpace_collapse(data->children->content); errno = 0; - ret->value.lval = strtol((char*)data->children->content, NULL, 0); - if (errno == ERANGE) { /* overflow */ - ret->value.dval = zend_strtod((char*)data->children->content, NULL); - ret->type = IS_DOUBLE; - } else { - ret->type = IS_LONG; + + switch ((Z_TYPE_P(ret) = is_numeric_string((char*)data->children->content, strlen((char*)data->children->content), &lval, &dval, 0))) { + case IS_LONG: + Z_LVAL_P(ret) = lval; + break; + case IS_DOUBLE: + Z_DVAL_P(ret) = dval; + break; + default: + soap_error0(E_ERROR, "Encoding: Violation of encoding rules"); } } else { soap_error0(E_ERROR, "Encoding: Violation of encoding rules"); diff --git a/ext/soap/tests/bugs/bug39832.phpt b/ext/soap/tests/bugs/bug39832.phpt new file mode 100755 index 0000000000..010b2e2689 --- /dev/null +++ b/ext/soap/tests/bugs/bug39832.phpt @@ -0,0 +1,29 @@ +--TEST-- +Bug #39832 (SOAP Server: parameter not matching the WSDL specified type are set to 0) +--SKIPIF-- + +--INI-- +soap.wsdl_cache_enabled=0 +--FILE-- + + + + +1 + + +EOF; + +function Test($x) { + return $x->priority; +} + +$x = new SoapServer(dirname(__FILE__)."/bug39832.wsdl"); +$x->addFunction("Test"); +$x->handle(); +?> +--EXPECT-- + +SOAP-ENV:ServerSOAP-ERROR: Encoding: Violation of encoding rules diff --git a/ext/soap/tests/bugs/bug39832.wsdl b/ext/soap/tests/bugs/bug39832.wsdl new file mode 100755 index 0000000000..a71f581dd5 --- /dev/null +++ b/ext/soap/tests/bugs/bug39832.wsdl @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.50.1