php.net |  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
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
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
Description:
------------
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


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-11-18 10:40 UTC] requinix@php.net
-Status: Open +Status: Duplicate
 [2016-11-18 10:40 UTC] requinix@php.net
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.

$yourResourceId=ssh2_connect($host,$port);

$sftp=intVal($yourResourceId);
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Dec 04 07:01:31 2024 UTC