php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53500 fread/feof doesn't detect the end of file using the sftp wrapper
Submitted: 2010-12-08 17:13 UTC Modified: 2010-12-08 17:22 UTC
From: sjaillet at gmail dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: Irrelevant OS: Ubuntu 10.4 LTS
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: sjaillet at gmail dot com
New email:
PHP Version: OS:

 

 [2010-12-08 17:13 UTC] sjaillet at gmail dot com
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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-08 17:22 UTC] johannes@php.net
-Status: Open +Status: Bogus
 [2010-12-08 17:22 UTC] johannes@php.net
please report this as bug against the ssh2 extension on pecl.php.net Thank You.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 23:01:32 2025 UTC