diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index 90708304..7b77f074 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -1214,7 +1214,7 @@ class Net_SFTP extends Net_SSH2 if ($this->use_stat_cache) { $result = $this->_query_stat_cache($filename); - if (is_array($result) && isset($result['.'])) { + if (is_array($result) && isset($result['.']) && isset($result['.']->lstat)) { return $result['.']->lstat; } if (is_object($result) && isset($result->lstat)) { diff --git a/tests/Functional/Net/SFTPUserStoryTest.php b/tests/Functional/Net/SFTPUserStoryTest.php index 730c2dbf..ca84ee65 100644 --- a/tests/Functional/Net/SFTPUserStoryTest.php +++ b/tests/Functional/Net/SFTPUserStoryTest.php @@ -427,8 +427,28 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase } /** - * on older versions this would result in a fatal error * @depends testReadlink + * @group github716 + */ + public function testStatOnCWD($sftp) + { + $stat = $sftp->stat('.'); + $this->assertInternalType( + 'array', $stat, + 'Failed asserting that stat on . returns an array' + ); + $lstat = $sftp->lstat('.'); + $this->assertInternalType( + 'array', $lstat, + 'Failed asserting that lstat on . returns an array' + ); + + return $sftp; + } + + /** + * on older versions this would result in a fatal error + * @depends testStatOnCWD * @group github402 */ public function testStatcacheFix($sftp)