mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-11-16 18:25:13 +00:00
Merge branch 'sftp-endless-loop' into sftp-endless-loop-v2
Conflicts: phpseclib/Net/SFTP.php tests/Functional/Net/SFTPUserStoryTest.php
This commit is contained in:
commit
0f49fb86bf
@ -1877,11 +1877,6 @@ class SFTP extends SSH2
|
|||||||
if ($local_start >= 0) {
|
if ($local_start >= 0) {
|
||||||
fseek($fp, $local_start);
|
fseek($fp, $local_start);
|
||||||
$size-= $local_start;
|
$size-= $local_start;
|
||||||
} elseif ($mode & self::RESUME_START) {
|
|
||||||
// do nothing
|
|
||||||
} else {
|
|
||||||
fseek($fp, $offset);
|
|
||||||
$size-= $offset;
|
|
||||||
}
|
}
|
||||||
} elseif ($dataCallback) {
|
} elseif ($dataCallback) {
|
||||||
$size = 0;
|
$size = 0;
|
||||||
|
@ -659,14 +659,20 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase
|
|||||||
* @depends testStatVsLstat
|
* @depends testStatVsLstat
|
||||||
* @group github830
|
* @group github830
|
||||||
*/
|
*/
|
||||||
public function testEndlessLoopOnUpload($sftp)
|
public function testUploadOffsets($sftp)
|
||||||
{
|
{
|
||||||
$sftp->put('endless.txt', 'res.txt', SFTP::SOURCE_LOCAL_FILE, 0, 10);
|
$sftp->put('offset.txt', 'res.txt', SFTP::SOURCE_LOCAL_FILE, 0, 10);
|
||||||
|
|
||||||
$this->assertSame(
|
$this->assertSame(
|
||||||
substr(self::$exampleData, 10),
|
substr(self::$exampleData, 10),
|
||||||
$sftp->get('endless.txt'),
|
$sftp->get('offset.txt'),
|
||||||
'Failed asserting that portions of a file could be uploaded.'
|
'Failed asserting that portions of a file could be uploaded.'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$sftp->put('offset.txt', 'res.txt', SFTP::SOURCE_LOCAL_FILE, self::$exampleDataLength - 100);
|
||||||
|
$this->assertSame(
|
||||||
|
substr(self::$exampleData, 10, -90) . self::$exampleData,
|
||||||
|
$sftp->get('offset.txt'),
|
||||||
|
'Failed asserting that you could upload into the middle of a file.'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user