php.net |  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: lampacz@php.net 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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: lampacz@php.net
New email:
PHP Version: OS:

 

 [2011-05-27 08:17 UTC] lampacz@php.net
Description:
------------
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)))
die('#1');

if (!ssh2_auth_password($oCon, $user, $pass))
die('#2');

$oSFTP = ssh2_sftp($oCon);

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

$aX = scandir($sDir);
print_r($aX);

Expected result:
----------------
At least if directory empty:
Array
(
    [0] => .
    [1] => ..
)

Actual result:
--------------
Array
(
)

Patches

Pull Requests

History

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] bjori@php.net
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 pecl.php.net.

In case this was a pecl.php.net 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: Tue Nov 12 20:01:30 2024 UTC