php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27187 fpassthru seems to not be binary safe
Submitted: 2004-02-08 21:57 UTC Modified: 2004-02-15 08:59 UTC
From: php at brokep dot com Assigned:
Status: No Feedback Package: Filesystem function related
PHP Version: 5.0.0b3 (beta3) OS: Tru64 v5.0a
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: php at brokep dot com
New email:
PHP Version: OS:

 

 [2004-02-08 21:57 UTC] php at brokep dot com
Description:
------------
While trying this code, my webpage was outputted as empty:

$fp=fopen("windowsfile.exe", "rb");
fpassthru($fp);


If I instead used echo the data i fread() it was no problem.
I tried fpassthru() with ELF-binaries and this was not a problem, only with the windows-binary file.

Reproduce code:
---------------
$client="/a/win32/binary/file.exe";

$fs=filesize($client);
$fp=fopen($client,"rb");
fpassthru($fp);


Expected result:
----------------
the contents of the $client-file

Actual result:
--------------
An empty webpage.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-02-08 22:21 UTC] moriyoshi@php.net
Which web server implementation are you using? (eg. 
Apache) and what is the version of it? (eg. 2.0.40)

And could you try it on the CLI version of PHP again?

 [2004-02-09 01:04 UTC] php at brokep dot com
PHP compililation flags:
--CUT--
./configure --with-apxs2=/apache/bin/apxs --with-mysql=/usr/local/mysql
--enable-track-vars --enable-inline-optimization --with-xml
--with-sockets --enable-sysvsem --enable-sysvshm --enable-sysvmsg
--with-gettext --with-xslt --with-imap=/usr/local/imap
--CUT--


Versions:
PHP 5.0.0b3
Apache2, 2.0.48
MySQL 5.0
newest libxml, libxslt, imap-2002e.

I tried the commandline PHP and - surprise - it worked like it should.
I can send you both the php-code and the win32binary that makes it not work.
 [2004-02-09 01:22 UTC] moriyoshi@php.net
1) If any of the following features is turned on in your php.ini, turn them off and try again.

 . output_handler=...
 . session.use_trans_sid=...
 . output_buffering=...

2) Try using file_get_contents() instead and see what'll happen.

<?php
echo file_get_contents('<your-cursed-win32-binary>");
?>


 [2004-02-09 02:02 UTC] php at brokep dot com
1. None of them are (nor was) activated.
2. file_get_contents() worked.

Is my binary a black hole? :)
 [2004-02-09 05:01 UTC] moriyoshi@php.net
OK, well, then check out your error_log. Is there any 
weird entry that starts with "Segmentation Fault", "bus 
error" or whatsoever you don't see unless fpassthru() is 
used?

If you find anything alike, then generate a backtrace 
with an appropriate debugger installed in your system.  
http://bugs.php.net/bugs-generating-backtrace.php might 
be helpful.




 [2004-02-15 08:59 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Nov 12 20:01:33 2019 UTC