Bug #72979 [NEW]: money_format stores wrong lenght value on AIX
| From: | matthieu dot sarter dot external at atos dot net | Date: | Tue, 30 Aug 2016 15:59:38 +0000 |
| Subject: | Bug #72979 [NEW]: money_format stores wrong lenght value on AIX | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-203688@lists.php.net to get a copy of this message | ||
From: matthieu dot sarter dot external at atos dot net
Operating system: AIX
PHP version: 7.0.10
Package: Strings related
Bug Type: Bug
Bug description:money_format stores wrong lenght value on AIX
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 bug report at https://bugs.php.net/bug.php?id=72979&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72979&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72979&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72979&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=72979&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=72979&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=72979&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=72979&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=72979&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=72979&r=support
Expected behavior: https://bugs.php.net/fix.php?id=72979&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=72979&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=72979&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=72979&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72979&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=72979&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=72979&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=72979&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=72979&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=72979&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=72979&r=mysqlcfg