From 23db2f7be3a229ba54139d0dfbae90649c371c0e Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sat, 26 Sep 2015 19:59:43 -0500 Subject: [PATCH 1/3] add unit test demo'ing issue # 830 --- tests/Functional/Net/SFTPUserStoryTest.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/Functional/Net/SFTPUserStoryTest.php b/tests/Functional/Net/SFTPUserStoryTest.php index b4e930ef..bbd5d4bc 100644 --- a/tests/Functional/Net/SFTPUserStoryTest.php +++ b/tests/Functional/Net/SFTPUserStoryTest.php @@ -649,5 +649,18 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase $this->assertSame($stat['type'], NET_SFTP_TYPE_SYMLINK); $sftp->enableStatCache(); + + //$sftp->chdir('..'); + + return $sftp; + } + + /** + * @depends testStatVsLstat + * @group github735 + */ + public function testEndlessLoopOnUpload($sftp) + { + $sftp->put('endless.txt', 'res.txt', NET_SFTP_LOCAL_FILE, 0, 10); } } From e2a2ad8c91d14762a48a4d1ed81c6ff78af0a803 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sun, 27 Sep 2015 10:56:05 -0500 Subject: [PATCH 2/3] SFTP: backport DavidAnderson684's changes to 1.0 branch --- phpseclib/Net/SFTP.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index 934ca44e..fb4a0be4 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -1917,10 +1917,12 @@ class Net_SFTP extends Net_SSH2 if ($local_start >= 0) { fseek($fp, $local_start); + $size-= $local_start; } elseif ($mode & NET_SFTP_RESUME_START) { // do nothing } else { fseek($fp, $offset); + $size-= $offset; } } elseif ($dataCallback) { $size = 0; From 759e04f08ec8e9bba854f3a12e69637eb8189c25 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sun, 27 Sep 2015 10:57:41 -0500 Subject: [PATCH 3/3] Tests/SFTP: updates to newly added unit test --- 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 bbd5d4bc..ceedcfa5 100644 --- a/tests/Functional/Net/SFTPUserStoryTest.php +++ b/tests/Functional/Net/SFTPUserStoryTest.php @@ -650,17 +650,21 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase $sftp->enableStatCache(); - //$sftp->chdir('..'); - return $sftp; } /** * @depends testStatVsLstat - * @group github735 + * @group github830 */ public function testEndlessLoopOnUpload($sftp) { $sftp->put('endless.txt', 'res.txt', NET_SFTP_LOCAL_FILE, 0, 10); + + $this->assertSame( + substr(self::$exampleData, 10), + $sftp->get('endless.txt'), + 'Failed asserting that portions of a file could be uploaded.' + ); } }