|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59943 ssh2_sftp_mkdir fails with trailing slash
Submitted: 2011-09-08 11:08 UTC Modified: 2011-09-21 14:42 UTC
From: james dot bench at spgroup dot co dot uk Assigned: bjori (profile)
Status: Closed Package: ssh2 (PECL)
PHP Version: 5.3.5 OS: Unbuntu 11.04 Server
Private report: No CVE-ID: None
 [2011-09-08 11:08 UTC] james dot bench at spgroup dot co dot uk
When attempting to create a directory using ssh2_sftp_mkdir the command will return false if the directory has a trailing slash, however the directory will be correctly created on the remote server.

Using the package from the Ubuntu 11.04 64bit repository, version 0.11.2-1.

Reproduce code:
$connection = ssh2_connect(...);
$sftp = ssh2_sftp($connection);

$dir = '/tmp/has/a/slash/';
var_dump(ssh2_sftp_mkdir($sftp, $dir, 0774, true)); // Returns false but the directory is created

$dir = '/tmp/has/no/slash';
var_dump(ssh2_sftp_mkdir($sftp, rtrim($dir, '/'), 0774, true)); // returns true and the directory is created

Expected result:
The code should print


and the directories /tmp/has/no/slash and /tmp/has/a/slash should both be created.

Actual result:
The code prints


and the directories /tmp/has/no/slash and /tmp/has/a/slash are both created.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-09-21 14:42 UTC]
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

In case this was a 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-2023 The PHP Group
All rights reserved.
Last updated: Sat Dec 02 09:01:27 2023 UTC