Bug #72979 [Opn->Csd]: money_format stores wrong lenght value on AIX
| From: | krakjoe@php.net | Date: | Mon, 09 Jan 2017 05:34:05 +0000 |
| Subject: | Bug #72979 [Opn->Csd]: money_format stores wrong lenght value on AIX | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-206419@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72979&edit=1
ID: 72979
Updated by: krakjoe@php.net
Reported by: matthieu dot sarter dot external at atos dot net
Summary: money_format stores wrong lenght value on AIX
-Status: Open
+Status: Closed
Type: Bug
Package: Strings related
Operating System: AIX
PHP Version: 7.0.10
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of krakjoe
Revision: http://git.php.net/?p=php-src.git;a=commit;h=8dd523a21604bfb0c8ac70367396507ce9fe77cb
Log: Fixed bug #72979 money_format stores wrong length on AIX
Previous Comments:
------------------------------------------------------------------------
[2016-08-30 15:59:35] matthieu dot sarter dot external at atos dot net
Description:
------------
On AIX strfmon seems to include the terminating \0 in the length returned by strfmon, despite the
documentation and the Open Group specifications indicating it is not included.
PHP's money_format function uses the value returned by strfmon as the length for the new ZSTR,
so this error is also present when using PHP on AIX.
The attached patch fixes this issue on PHP side, by using strlen after strfmon to get the size
without the trailing \0 (tested with PHP 7.0.3, 7.0.7, 7.0.9 and 7.0.10 on AIX 6.1).
Test script:
---------------
// From ext/standard/tests/strings/moneyformat.phpt
setlocale(LC_MONETARY, 'en_US');
var_dump( money_format("X%nY", 3.1415));
Expected result:
----------------
string(7) "X$3.14Y"
Actual result:
--------------
string(8) "X$3.14Y"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72979&edit=1