From 9ea67f9edb75078c8439ed42b7c27c9a6222a85f Mon Sep 17 00:00:00 2001 From: Julius Beckmann Date: Wed, 20 Nov 2013 14:49:16 +0100 Subject: [PATCH 1/2] Making Net_SFTP::chdir capable of handling the empty string. Fixing a ugly notice when using the empty string as parameter for chdir: Notice: Uninitialized string offset: -1 in Net/SFTP.php line 617 --- phpseclib/Net/SFTP.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index 5356ffbf..020d59be 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -635,7 +635,8 @@ class Net_SFTP extends Net_SSH2 { return false; } - if ($dir[strlen($dir) - 1] != '/') { + // Suffix a slash + if (!$dir || $dir[strlen($dir) - 1] != '/') { $dir.= '/'; } From 44078e5f40ce7311df0e97a68405fb1137377d41 Mon Sep 17 00:00:00 2001 From: Julius Beckmann Date: Wed, 20 Nov 2013 15:08:50 +0100 Subject: [PATCH 2/2] Making Net_SFTP::chdir capable of handling the empty string. Updated patch after hint from bantu. --- phpseclib/Net/SFTP.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index 020d59be..5ebf9d28 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -635,8 +635,12 @@ class Net_SFTP extends Net_SSH2 { return false; } - // Suffix a slash - if (!$dir || $dir[strlen($dir) - 1] != '/') { + if ($dir === '') { + $dir = './'; + } + + // Suffix a slash if needed + if ($dir[strlen($dir) - 1] != '/') { $dir.= '/'; }