Bug #66674 [NEW]: Invalid printf() conversion code in json.c (twice)
| From: | tom at bignm dot com | Date: | Sat, 08 Feb 2014 12:18:23 +0000 |
| Subject: | Bug #66674 [NEW]: Invalid printf() conversion code in json.c (twice) | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-184205@lists.php.net to get a copy of this message | ||
From: tom at bignm dot com
Operating system: Ubuntu Linux 11.04
PHP version: 5.4.25
Package: Compile Warning
Bug Type: Bug
Bug description:Invalid printf() conversion code in json.c (twice)
Description:
------------
When compiling PHP 5.4.25 two compilation warnings are displayed
indicating an invalid printf() conversion code 'k' being used. On lines
408 and 619 inside a spprintf() calls, the following lines are found in
source file 'json.c':
409: int l = spprintf(&tmp, 0, "%.*k", (int) EG(precision), d);
619: len = spprintf(&d, 0, "%.*k", (int) EG(precision), dbl);
My suspicion is that the conversion code should be 'e', 'f' or 'g'
instead of 'k' since the value seems to be a double being processed in
both cases with a fixed precision.
While only a warning, this can certainly cause invalid floating point
values to be returned, possibly even causing segmentation faults in
spprintf().
Test script:
---------------
Not needed.
Expected result:
----------------
Hopefully somebody will fix the source who knows which proper printf()
conversion code to use.
Actual result:
--------------
Here's the 'make' line and the compiler's output for the file
'json.c':
/bin/bash /usr/local/src/php-5.4.25/libtool --silent --preserve-dup-deps
--mode=compile cc -Iext/json/ -I/usr/local/src/php-5.4.25/ext/json/
-DPHP_ATOM_INC -I/usr/local/src/php-5.4.25/include
-I/usr/local/src/php-5.4.25/main -I/usr/local/src/php-5.4.25
-I/usr/local/src/php-5.4.25/ext/date/lib
-I/usr/local/src/php-5.4.25/ext/ereg/regex -I/usr/include/libxml2
-I/usr/include/freetype2
-I/usr/local/src/php-5.4.25/ext/mbstring/oniguruma
-I/usr/local/src/php-5.4.25/ext/mbstring/libmbfl
-I/usr/local/src/php-5.4.25/ext/mbstring/libmbfl/mbfl
-I/usr/include/mysql -I/usr/local/src/php-5.4.25/ext/sqlite3/libsqlite
-I/usr/local/src/php-5.4.25/TSRM -I/usr/local/src/php-5.4.25/Zend
-I/usr/include -g -O2 -fvisibility=hidden -c
/usr/local/src/php-5.4.25/ext/json/json.c -o ext/json/json.lo
/usr/local/src/php-5.4.25/ext/json/json.c: In function
'json_escape_string':
/usr/local/src/php-5.4.25/ext/json/json.c:408:6: warning: unknown
conversion type character 'k' in format
/usr/local/src/php-5.4.25/ext/json/json.c: In function
'php_json_encode':
/usr/local/src/php-5.4.25/ext/json/json.c:619:6: warning: unknown
conversion type character 'k' in format
--
Edit bug report at https://bugs.php.net/bug.php?id=66674&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66674&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66674&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66674&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=66674&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=66674&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=66674&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=66674&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=66674&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=66674&r=support
Expected behavior: https://bugs.php.net/fix.php?id=66674&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=66674&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=66674&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=66674&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66674&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=66674&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=66674&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=66674&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=66674&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=66674&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=66674&r=mysqlcfg