From: Operating system: Ubuntu 10.4 LTS PHP version: Irrelevant Package: Filesystem function related Bug Type: Bug Bug description:fread/feof doesn't detect the end of file using the sftp wrapper
Description: ------------ fread/feof doesn't detect the end of file using the sftp wrapper. an infinite loop occurcs when trying to read files. OS: Ubuntu 10.4 TLS PHP version : 5.3.2-1ubuntu4.5 openssh-server : 1:5.3p1-3ubuntu4 Test script: --------------- #!/usr/bin/php <?php $connection = ssh2_connect('my.hostname.com', 22); ssh2_auth_password($connection, 'mylogin', 'mypassword'); $sftp = ssh2_sftp($connection); $stream = fopen('ssh2.sftp://'.$sftp.'/home/mylogin/test', 'w'); fwrite($stream, "bob"); fclose($stream); print_r(file_get_contents('ssh2.sftp://'.$sftp.'/home/mylogin/test')); //Works fine ! $source_handle = fopen('ssh2.sftp://'.$sftp.'/home/mylogin/test', "r"); if($source_handle){ while (!feof($source_handle)) { //Infinite loop $buffer = fread($source_handle,1024); echo "*".$buffer."*"; } fclose($source_handle); } ?> Expected result: ---------------- bob*bob* Actual result: -------------- bob*bob*********************************************... and so on. -- Edit bug report at http://bugs.php.net/bug.php?id=53500&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53500&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53500&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53500&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=53500&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53500&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=53500&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=53500&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=53500&r=needscript Try newer version: http://bugs.php.net/fix.php?id=53500&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=53500&r=support Expected behavior: http://bugs.php.net/fix.php?id=53500&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=53500&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=53500&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=53500&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53500&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=53500&r=dst IIS Stability: http://bugs.php.net/fix.php?id=53500&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=53500&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=53500&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=53500&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=53500&r=mysqlcfg