php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22227 printf() field limiters broke between 4.2.3 and 4.3.0
Submitted: 2003-02-14 17:59 UTC Modified: 2003-02-15 10:01 UTC
From: andy at petdance dot com Assigned: moriyoshi (profile)
Status: Closed Package: Output Control
PHP Version: 4.3.0 / 4CVS-2003-02-16 / 5CVS-2003-02-16 OS: Linux
Private report: No CVE-ID: None
 [2003-02-14 17:59 UTC] andy at petdance dot com
Witness the following code:

printf( "PHP Version=%s\n", phpversion() );
print "Output should be [abc] in all cases\n";

$masks = Array( "%-3.3s", "%.3s", "%-.3s" );
$str = "abcdefg";
foreach ( $masks as $mask ) {
    printf( "[$mask] <-- %s\n", $str, $mask );
}

Under 4.2.3 we get:
PHP Version=4.2.3
Output should be [abc] in all cases
[abc] <-- %-3.3s
[abc] <-- %.3s
[abc] <-- %-.3s

Under 4.3.0 we get:
PHP Version=4.3.0
Output should be [abc] in all cases
[abcdefg] <-- %-3.3s
[abc] <-- %.3s
[abc] <-- %-.3s

This breaks a TON of column-formatting code for our application.  We're reverting to 4.2.3 until this is fixed.

The test suite in ext/standard/tests/general_functions/001.phpt does not test that specific combination of width & precision.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-02-15 09:27 UTC] moriyoshi@php.net
Related to bug #20108
 [2003-02-15 10:01 UTC] moriyoshi@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 [2012-11-12 22:33 UTC] salathe@php.net
Automatic comment from SVN on behalf of salathe
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=328332
Log: count() does in fact discover recursion and issues an E_WARNING in response... but it will probably return a much higher number than it should. (doc #63406)

--
Provided by anonymous #22227 (mail+php@requinix.net)
 [2012-11-12 22:33 UTC] salathe@php.net
Automatic comment from SVN on behalf of salathe
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=328333
Log: exif_imagetype (actually standard/image.c, php_getimagetype) requires between 3 and 12 bytes in a file, otherwise it E_NOTICEs. (doc #63329)

--
Provided by anonymous #22227 (mail+php@requinix.net)
 [2012-11-12 22:34 UTC] salathe@php.net
Automatic comment from SVN on behalf of salathe
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=328334
Log: Fix missing parenthesis in comment in example

--
Provided by anonymous #22227 (mail+php@requinix.net)
 [2012-11-12 22:34 UTC] salathe@php.net
Automatic comment from SVN on behalf of salathe
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=328335
Log: Adding a note that shutdown functions won't be executed if the script gets a SIGTERM or SIGKILL, though you can pcntl_signal() for the TERM and exit;. (doc #63275)

--
Provided by anonymous #22227 (mail+php@requinix.net)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 10:01:30 2024 UTC