|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59789 using ssh2.sftp stream on 64bit vs. 32bit
Submitted: 2011-05-27 08:17 UTC Modified: 2011-09-21 13:08 UTC
From: Assigned: bjori (profile)
Status: Closed Package: ssh2 (PECL)
PHP Version: 5.3.5 OS: Linux
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.
Bug Type:
New email:
PHP Version: OS:


 [2011-05-27 08:17 UTC]
On 32bit system works scandir/opendir+readdir with ssh2.sftp ok but on 64bit system is problem - empty array. Tried on 5.3.2 and same results. I don't know if it's problem of ssh2 or global in scandir/opendir+readdir

Reproduce code:
if (!($oCon = ssh2_connect($host, $port)))

if (!ssh2_auth_password($oCon, $user, $pass))

$oSFTP = ssh2_sftp($oCon);

$sDir = "ssh2.sftp://$oSFTP/";

$aX = scandir($sDir);

Expected result:
At least if directory empty:
    [0] => .
    [1] => ..

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-13 14:02 UTC] sts at tradebyte dot biz
This seems to be a bug in ssh2_sftp.c, which passes an int-pointer to php_basename, however the latter treats it as a size_t-pointer.

diff -ur php-ssh2-0.11.0/ssh2-0.11.0/ssh2_sftp.c php-ssh2-0.11.0.orig/ssh2-0.11.0/ssh2_sftp.c
--- php-ssh2-0.11.0.orig/ssh2-0.11.0/ssh2_sftp.c        2008-12-02 23:12:34.000000000 +0100
+++ php-ssh2-0.11.0/ssh2-0.11.0/ssh2_sftp.c     2011-07-13 17:09:47.000000000 +0200
@@ -262,7 +262,7 @@
        php_stream_dirent *ent = (php_stream_dirent*)buf;
        size_t bytesread = libssh2_sftp_readdir(data->handle, ent->d_name, sizeof(ent->d_name) - 1, NULL);
        char *basename = NULL;
-       int basename_len = 0;
+       size_t basename_len = 0;
        if (bytesread <= 0) {
                return 0;
 [2011-09-21 13:08 UTC]
This bug has been fixed in SVN.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on

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

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 01 12:01:29 2024 UTC