php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73431 Loss of precision with xsd:integer and other huge integer types
Submitted: 2016-10-31 15:45 UTC Modified: 2019-09-28 23:45 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: perske at uni-muenster dot de Assigned:
Status: Open Package: SOAP related
PHP Version: 7.2.21 OS: all
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2016-10-31 15:45 UTC] perske at uni-muenster dot de
Description:
------------
If a server returns a use integer like in
<Serial xsi:type="xsd:integer">8688597941889535165991696066</Serial>
The PHP script does not get the complete huge integer but a rounded float like
86885979418895E+27
This is inacceptable for most use cases.

To fix, modify ext/soap/php_encoding.c: Replace the line:
{{XSD_INTEGER, XSD_INTEGER_STRING, XSD_NAMESPACE, NULL}, to_zval_long, to_xml_long},
with the line
{{XSD_INTEGER, XSD_INTEGER_STRING, XSD_NAMESPACE, NULL}, to_zval_stringc, to_xml_string},

The same should be done with these lines:
{{XSD_NONPOSITIVEINTEGER, XSD_NONPOSITIVEINTEGER_STRING, XSD_NAMESPACE, NULL}, to_zval_long, to_xml_long},
{{XSD_POSITIVEINTEGER, XSD_POSITIVEINTEGER_STRING, XSD_NAMESPACE, NULL}, to_zval_long, to_xml_long},
{{XSD_NONNEGATIVEINTEGER, XSD_NONNEGATIVEINTEGER_STRING, XSD_NAMESPACE, NULL}, to_zval_long, to_xml_long},
{{XSD_NEGATIVEINTEGER, XSD_NEGATIVEINTEGER_STRING, XSD_NAMESPACE, NULL}, to_zval_long, to_xml_long},
{{XSD_INTEGER, XSD_INTEGER_STRING, XSD_NAMESPACE, NULL}, to_zval_long, to_xml_long},


Test script:
---------------
n/a


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-10-31 16:51 UTC] perske at uni-muenster dot de
The change from to_xml_long to to_xml_string is not necessary,
but to_zval_long must be changed to to_zval_stringc (or to_zval_string).
 [2019-09-28 23:45 UTC] perske at uni-muenster dot de
-PHP Version: 7.0.12 +PHP Version: 7.2.21
 [2019-09-28 23:45 UTC] perske at uni-muenster dot de
Please check and implement the fix I have proposed. It hardly does break anything and it helps in many use cases of SOAP.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Dec 09 18:01:24 2019 UTC