php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48802 printf() returns incorrect outputted length
Submitted: 2009-07-05 09:47 UTC Modified: 2010-12-20 12:44 UTC
From: andrey dot vihrov at gmail dot com Assigned: jani (profile)
Status: Closed Package: Output Control
PHP Version: 5.*, 6CVS (2009-07-06) OS: Gentoo Linux amd64
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: andrey dot vihrov at gmail dot com
New email:
PHP Version: OS:

 

 [2009-07-05 09:47 UTC] andrey dot vihrov at gmail dot com
Description:
------------
There is no way to tell that output to STDOUT/STDERR failed.

Configure Command =>  './configure'  '--prefix=/usr/lib64/php5' '--host=x86_64-pc-linux-gnu' '--mandir=/usr/lib64/php5/man' '--infodir=/usr/lib64/php5/info' '--sysconfdir=/etc' '--cache-file=./config.cache' '--with-libdir=lib64' '--with-pcre-regex=/usr' '--enable-cli' '--disable-cgi' '--with-config-file-path=/etc/php/cli-php5' '--with-config-file-scan-dir=/etc/php/cli-php5/ext-active' '--without-pear' '--disable-bcmath' '--with-bz2' '--disable-calendar' '--disable-ctype' '--without-curl' '--without-curlwrappers' '--disable-dbase' '--enable-exif' '--without-fbsql' '--without-fdftk' '--disable-filter' '--disable-ftp' '--with-gettext' '--without-gmp' '--disable-hash' '--disable-ipv6' '--disable-json' '--without-kerberos' '--enable-mbstring' '--with-mcrypt' '--without-mhash' '--without-msql' '--without-mssql' '--with-ncurses' '--with-openssl' '--with-openssl-dir=/usr' '--disable-pcntl' '--disable-pdo' '--without-pgsql' '--disable-posix' '--with-pspell' '--without-recode' '--disable-simplexml' '--disable-shmop' '--without-snmp' '--disable-soap' '--disable-sockets' '--without-sybase' '--without-sybase-ct' '--disable-sysvmsg' '--disable-sysvsem' '--disable-sysvshm' '--without-tidy' '--disable-tokenizer' '--disable-wddx' '--disable-xmlreader' '--disable-xmlwriter' '--without-xmlrpc' '--without-xsl' '--disable-zip' '--with-zlib' '--disable-debug' '--enable-dba' '--without-cdb' '--with-db4' '--disable-flatfile' '--with-gdbm' '--disable-inifile' '--without-qdbm' '--with-freetype-dir=/usr' '--with-t1lib=/usr' '--disable-gd-jis-conv' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--without-xpm-dir' '--with-gd' '--without-mysqli' '--with-readline' '--without-libedit' '--without-mm' '--with-sqlite=/usr' '--enable-sqlite-utf8'

> diff php.ini-dist /etc/php/cli-php5/php.ini 
474c474
< ;include_path = ".:/php/includes"
---
> include_path = ".:/usr/share/php5:/usr/share/php"
491c491
< extension_dir = "./"
---
> extension_dir = /usr/lib64/php5/lib/php/extensions/no-debug-non-zts-20060613
560c560
< allow_url_fopen = On
---
> allow_url_fopen = Off
1283a1284,1288
> 
> ; MySQL extensions default connection charset settings
> ;mysql.connect_charset = utf8
> ;mysqli.connect_charset = utf8
> ;pdo_mysql.connect_charset = utf8

Reproduce code:
---------------
#! /usr/bin/php
<?
	$s = "Hello World\n";

	if (printf($s) != strlen($s))
		exit(1);

	if (fclose(STDOUT) != TRUE)
		exit(1);
?>

Expected result:
----------------
A /dev/full pseudo-device in Linux is "always full", and any writes to it fail. When run as "./test.php > /dev/full", the script should exit unsuccessfully (with exit status 1).

Actual result:
--------------
> ./test.php > /dev/full
> echo $?
0


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-07-05 11:21 UTC] sjoerd-php at linuxonly dot nl
See bug #48803.
 [2009-07-06 13:27 UTC] jani@php.net
Here's a patch that should fix this:

  http://pecl.php.net/~jani/patches/bug48802.patch

 [2009-07-07 14:40 UTC] jani@php.net
I updated the patch to actually work as it should plus fixed same issue in vprintf(). (thanks Ilia :)
 [2009-07-23 14:54 UTC] svn@php.net
Automatic comment from SVN on behalf of jani
Revision: http://svn.php.net/viewvc/?view=revision&revision=284649
Log: - Fixed bug #48802 (printf() returns incorrect outputted length)
 [2009-07-23 14:54 UTC] jani@php.net
This bug has been fixed in SVN.

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/.
 
Thank you for the report, and for helping us make PHP better.


 [2010-12-20 12:44 UTC] jani@php.net
-Package: Tidy +Package: Output Control
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 02:01:29 2024 UTC