mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-12-26 11:37:33 +00:00
Merge pull request #833 from terrafrost/sftp-endless-loop
SFTP.php : prevent endless loop when upload completed with non-zero $start or $local_start for 1.0 * terrafrost/sftp-endless-loop: SFTP: don't start in local file middle when uploading to middle of the remote file Tests/SFTP: updates to newly added unit test SFTP: backport DavidAnderson684's changes to 1.0 branch add unit test demo'ing issue # 830
This commit is contained in:
commit
c0e42ad751
@ -1917,10 +1917,7 @@ class Net_SFTP extends Net_SSH2
|
||||
|
||||
if ($local_start >= 0) {
|
||||
fseek($fp, $local_start);
|
||||
} elseif ($mode & NET_SFTP_RESUME_START) {
|
||||
// do nothing
|
||||
} else {
|
||||
fseek($fp, $offset);
|
||||
$size-= $local_start;
|
||||
}
|
||||
} elseif ($dataCallback) {
|
||||
$size = 0;
|
||||
|
@ -649,5 +649,28 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase
|
||||
$this->assertSame($stat['type'], NET_SFTP_TYPE_SYMLINK);
|
||||
|
||||
$sftp->enableStatCache();
|
||||
|
||||
return $sftp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testStatVsLstat
|
||||
* @group github830
|
||||
*/
|
||||
public function testUploadOffsets($sftp)
|
||||
{
|
||||
$sftp->put('offset.txt', 'res.txt', NET_SFTP_LOCAL_FILE, 0, 10);
|
||||
$this->assertSame(
|
||||
substr(self::$exampleData, 10),
|
||||
$sftp->get('offset.txt'),
|
||||
'Failed asserting that portions of a file could be uploaded.'
|
||||
);
|
||||
|
||||
$sftp->put('offset.txt', 'res.txt', NET_SFTP_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