diff options
| author | Dmitry Stogov <dmitry@php.net> | 2006-12-18 14:39:23 +0000 |
|---|---|---|
| committer | Dmitry Stogov <dmitry@php.net> | 2006-12-18 14:39:23 +0000 |
| commit | 6e0b78cd4c5735df1f0c4a17e29773a4aa685453 (patch) | |
| tree | 048f47816d5a56d174aaed2d58d4bbf54a5169d4 /ext/soap/php_encoding.c | |
| parent | 908b1e562d5e2a586ca721e779afedb958d92067 (diff) | |
| download | php-git-6e0b78cd4c5735df1f0c4a17e29773a4aa685453.tar.gz | |
Fixed bug #39832 (SOAP Server: parameter not matching the WSDL specified type are set to 0)
Diffstat (limited to 'ext/soap/php_encoding.c')
| -rw-r--r-- | ext/soap/php_encoding.c | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c index eb1b2f2595..b401d6d430 100644 --- a/ext/soap/php_encoding.c +++ b/ext/soap/php_encoding.c @@ -669,9 +669,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"); @@ -708,6 +714,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') { @@ -716,6 +724,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'; @@ -858,8 +868,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"); } @@ -877,14 +901,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"); |
