Fix #77141: Signedness issue in SOAP when precision=-1

According to php_gcvt(), we assume at most 17 fractional digits for
negative precision.
This commit is contained in:
Christoph M. Becker 2018-11-12 23:00:25 +01:00
parent 625f614cb1
commit f6079e3c56
3 changed files with 29 additions and 1 deletions

1
NEWS
View file

@ -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

View file

@ -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);

View file

@ -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===