From 26818ebb400848b93689b532cc20e38a0a15ad26 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Fri, 26 Jun 2015 22:25:22 -0500 Subject: [PATCH 1/4] Tests/SFTP: add test for stat's on . --- tests/Functional/Net/SFTPUserStoryTest.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/Functional/Net/SFTPUserStoryTest.php b/tests/Functional/Net/SFTPUserStoryTest.php index 730c2dbf..dccdfe5c 100644 --- a/tests/Functional/Net/SFTPUserStoryTest.php +++ b/tests/Functional/Net/SFTPUserStoryTest.php @@ -427,8 +427,24 @@ 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('.'); + $lstat = $sftp->lstat('.'); + $this->assertEquals( + $stat, $lstat, + 'Failed asserting that stat and lstat on . are the same' + ); + + return $sftp; + } + + /** + * on older versions this would result in a fatal error + * @depends testStatOnCWD * @group github402 */ public function testStatcacheFix($sftp) From d1d415618aa88a661a94872088c6323699e55134 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Fri, 26 Jun 2015 23:34:14 -0500 Subject: [PATCH 2/4] SFTP: update conditions under which cache for lstat / . is used --- phpseclib/Net/SFTP.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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)) { From df65acb9994b318da18d8da8d5a3be678e1827da Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sat, 27 Jun 2015 07:43:35 -0500 Subject: [PATCH 3/4] Tests/SFTP: just check to see that stat / lstat return an array --- tests/Functional/Net/SFTPUserStoryTest.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/Functional/Net/SFTPUserStoryTest.php b/tests/Functional/Net/SFTPUserStoryTest.php index dccdfe5c..79e381ea 100644 --- a/tests/Functional/Net/SFTPUserStoryTest.php +++ b/tests/Functional/Net/SFTPUserStoryTest.php @@ -433,10 +433,14 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase public function testStatOnCWD($sftp) { $stat = $sftp->stat('.'); + $this->assertInternalType( + 'array', $lstat, + 'Failed asserting that stat on . returns an array' + ); $lstat = $sftp->lstat('.'); - $this->assertEquals( - $stat, $lstat, - 'Failed asserting that stat and lstat on . are the same' + $this->assertInternalType( + 'array', $lstat, + 'Failed asserting that lstat on . returns an array' ); return $sftp; From fb3bd8adff874cc39f466177f26c784ea7e23659 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sat, 27 Jun 2015 07:56:47 -0500 Subject: [PATCH 4/4] Tests/SFTP: $lstat->$stat --- tests/Functional/Net/SFTPUserStoryTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Functional/Net/SFTPUserStoryTest.php b/tests/Functional/Net/SFTPUserStoryTest.php index 79e381ea..ca84ee65 100644 --- a/tests/Functional/Net/SFTPUserStoryTest.php +++ b/tests/Functional/Net/SFTPUserStoryTest.php @@ -434,7 +434,7 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase { $stat = $sftp->stat('.'); $this->assertInternalType( - 'array', $lstat, + 'array', $stat, 'Failed asserting that stat on . returns an array' ); $lstat = $sftp->lstat('.');