Bug #66674 [Opn->Nab]: Invalid printf() conversion code in json.c (twice)

From: Date: Sat, 08 Feb 2014 12:59:22 +0000
Subject: Bug #66674 [Opn->Nab]: Invalid printf() conversion code in json.c (twice)
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-184206@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66674&edit=1 ID: 66674 Updated by: nikic@php.net Reported by: tom at bignm dot com Summary: Invalid printf() conversion code in json.c (twice) -Status: Open +Status: Not a bug Type: Bug Package: Compile Warning Operating System: Ubuntu Linux 11.04 PHP Version: 5.4.25 Block user comment: N Private report: N New Comment: k is a custom modifier that prints a floating point number without taking locales into consideration. Is there some way to teach gcc about custom printf modifiers? Previous Comments: ------------------------------------------------------------------------ [2014-02-08 12:18:22] tom at bignm dot com 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 this bug report at https://bugs.php.net/bug.php?id=66674&edit=1

« previous php.bugs (#184206) next »