php.net |  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: -
Votes:1
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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
1 + 29 = ?
Subscribe to this entry?

 
 [2016-08-30 15:59 UTC] 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"

Patches

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

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-09 05:34 UTC] krakjoe@php.net
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
 [2017-01-09 05:34 UTC] krakjoe@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 05:01:30 2024 UTC