|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73556 Regression in mkdir() with ssh2 extension wrapper URL (ssh2.sftp://...)
Submitted: 2016-11-17 17:00 UTC Modified: 2016-11-17 17:15 UTC
From: jerome dot auge at anakeen dot com Assigned:
Status: Duplicate Package: URL related
PHP Version: 5.6.28 OS: Linux
Private report: No CVE-ID: None
 [2016-11-17 17:00 UTC] jerome dot auge at anakeen dot com
After upgrading to PHP 5.6.28 it is not possible to create directories with the mkdir("ssh2.sftp://Resource id #5/somepath") notation: the mkdir() call returns bool(false) and the directory is not created on the remote host.

After instrumenting `ssh2_fopen_wrappers.c` and `ext/standard/url.c` I found that the problem is that the call to php_url_parse("ssh2.sftp://Resource id #5/somepath") is returning a resource->path set to NULL.

Reverting the change introduced by #73192 (, a call to mkdir("ssh2.sftp://Resource id #5/somepath") correctly creates the remote dir and returns bool(true).

The ssh2 extension relies on the '#' character in the hostname part of the URL to detect the underlying resource.

Test script:
$username   = "sftp";
$hostname   = "";
$port       = 22;
$pk         = "/path/to/";
$sk         = "/path/to/id_rsa";
$passphrase = "";
$dir        = "/home/sftp/xxx";

$conn_ssh = ssh2_connect($hostname, $port);
ssh2_auth_pubkey_file($conn_ssh, $username, $pk, $sk, $passphrase);
$conn_sftp = ssh2_sftp($conn_ssh)

$uri = sprintf("ssh2.sftp://%s/%s", $conn_sftp, $dir);
if (mkdir($uri) === false) {
  printf("Error creating directory '%s'\n", $uri);

Expected result:

Actual result:
Error creating directory 'ssh2.sftp://Resource id #5//home/sftp/xxx'


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-11-17 17:15 UTC]
-Status: Open +Status: Duplicate
 [2016-11-17 17:15 UTC]
Duplicate of bug #73506
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 11:01:27 2024 UTC