|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73561 opendir() using a ssh2.sftp:// resource does not work
Submitted: 2016-11-18 10:10 UTC Modified: 2016-11-18 10:40 UTC
From: sascha dot pfalz at ivz dot de Assigned:
Status: Duplicate Package: Directory function related
PHP Version: 7.0.13 OS: Red Hat Linux 7.2
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:
From: sascha dot pfalz at ivz dot de
New email:
PHP Version: OS:


 [2016-11-18 10:10 UTC] sascha dot pfalz at ivz dot de
I'm using the ssh2 Extension (1.0) together with PHP 7 to work on SSH enabled servers.
When trying to read a directory on the SSH2 via the ssh2.sftp:// wrapper, I've got the following error under 7.0.13:

PHP Warning:  opendir(ssh2.sftp://Resource id #49/test): failed to open dir: operation failed

Using exactly the same code with the same ssh2 extension under PHP 7.0.12 everything works as expected.

Test script:
$dirname  = sprintf("ssh2.sftp://%s%s",$this->SFTP,"/test");
$handle   = opendir($dirname);

Expected result:
Getting a directory handle ready to traverse the entries with readdir().

Actual result:
$handle is boolean(false) instead of directory handle, and this warning is printed:

PHP Warning:  opendir(ssh2.sftp://Resource id #7/ivz-export/test/): failed to open dir: operation failed in ivz_sftp2.class.php on line 98


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-11-18 10:40 UTC]
-Status: Open +Status: Duplicate
 [2016-11-18 10:40 UTC]
Another duplicate of bug #73506
 [2017-03-16 04:59 UTC] rahul dot thacker at radixweb dot com
As per improved path security, this type of path is not allowed in later versions of php, I got working solution by converting resource Id to integer.


PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Jan 20 05:01:23 2021 UTC