diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2018-11-12 23:00:25 +0100 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2018-11-12 23:19:30 +0100 |
commit | f6079e3c56eabe03565faceaef9de12728d278bf (patch) | |
tree | 571d068d37bddce4f5c9a6d86639942a763e8ea1 | |
parent | 625f614cb13536d805985a2008840452c6c86a26 (diff) | |
download | php-git-f6079e3c56eabe03565faceaef9de12728d278bf.tar.gz |
Fix #77141: Signedness issue in SOAP when precision=-1
According to php_gcvt(), we assume at most 17 fractional digits for
negative precision.
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | ext/soap/php_encoding.c | 2 | ||||
-rw-r--r-- | ext/soap/tests/bugs/bug77141.phpt | 27 |
3 files changed, 29 insertions, 1 deletions
@@ -11,6 +11,7 @@ PHP NEWS - SOAP: . Fixed bug #76348 (WSDL_CACHE_MEMORY causes Segmentation fault). (cmb) + . Fixed bug #77141 (Signedness issue in SOAP when precision=-1). (cmb) 08 Nov 2018, PHP 7.1.24 diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c index 1198eaf601..6fc2c19817 100644 --- a/ext/soap/php_encoding.c +++ b/ext/soap/php_encoding.c @@ -1098,7 +1098,7 @@ static xmlNodePtr to_xml_double(encodeTypePtr type, zval *data, int style, xmlNo ZVAL_DOUBLE(&tmp, zval_get_double(data)); - str = (char *) safe_emalloc(EG(precision), 1, MAX_LENGTH_OF_DOUBLE + 1); + str = (char *) safe_emalloc(EG(precision) >= 0 ? EG(precision) : 17, 1, MAX_LENGTH_OF_DOUBLE + 1); php_gcvt(Z_DVAL(tmp), EG(precision), '.', 'E', str); xmlNodeSetContentLen(ret, BAD_CAST(str), strlen(str)); efree(str); diff --git a/ext/soap/tests/bugs/bug77141.phpt b/ext/soap/tests/bugs/bug77141.phpt new file mode 100644 index 0000000000..fa38cc6959 --- /dev/null +++ b/ext/soap/tests/bugs/bug77141.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #77141 (Signedness issue in SOAP when precision=-1) +--SKIPIF-- +<?php +if (!extension_loaded('soap')) die('skip soap extension not available'); +?> +--FILE-- +<?php +$soap = new \SoapClient( + null, + array( + 'location' => "http://localhost/soap.php", + 'uri' => "http://localhost/", + 'style' => SOAP_RPC, + 'trace' => true, + 'exceptions' => false, + ) +); +ini_set('precision', -1); +$soap->call(1.1); +echo $soap->__getLastRequest(); +?> +===DONE=== +--EXPECT-- +<?xml version="1.0" encoding="UTF-8"?> +<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://localhost/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:call><param0 xsi:type="xsd:float">1.1</param0></ns1:call></SOAP-ENV:Body></SOAP-ENV:Envelope> +===DONE=== |