|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72979 money_format stores wrong lenght value on AIX
Submitted: 2016-08-30 15:59 UTC Modified: -
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:-1 (-100.0%)
From: matthieu dot sarter dot external at atos dot net Assigned:
Status: Closed Package: Strings related
PHP Version: 7.0.10 OS: AIX
Private report: No CVE-ID: None
 [2016-08-30 15:59 UTC] matthieu dot sarter dot external at atos dot net
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"


php-7.0.3-aix-strfmon.patch (last revision 2016-08-30 15:59 UTC by matthieu dot sarter dot external at atos dot net)

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-09 05:34 UTC]
Automatic comment on behalf of krakjoe
Log: Fixed bug #72979 money_format stores wrong length on AIX
 [2017-01-09 05:34 UTC]
-Status: Open +Status: Closed
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 23 21:01:30 2024 UTC