|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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
(
)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 11:00:01 2025 UTC |
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;