fix #15973
Rework of stream_seek handling; there where basically two bugs: 1. seeking to the end of the current file would fail (with SEEK_SET); and 2. if seeking to an undefined position (outside 0,unencryptedSize) then newPosition was not defined. I used the opportunity to simplify the code.
This commit is contained in:
parent
41d7870d7b
commit
f5415653fd
1 changed files with 7 additions and 9 deletions
|
@ -356,24 +356,22 @@ class Encryption extends Wrapper {
|
|||
|
||||
switch ($whence) {
|
||||
case SEEK_SET:
|
||||
if ($offset < $this->unencryptedSize && $offset >= 0) {
|
||||
$newPosition = $offset;
|
||||
}
|
||||
break;
|
||||
case SEEK_CUR:
|
||||
if ($offset >= 0) {
|
||||
$newPosition = $offset + $this->position;
|
||||
}
|
||||
$newPosition = $this->position + $offset;
|
||||
break;
|
||||
case SEEK_END:
|
||||
if ($this->unencryptedSize + $offset >= 0) {
|
||||
$newPosition = $this->unencryptedSize + $offset;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return $return;
|
||||
}
|
||||
|
||||
if ($newPosition > $this->unencryptedSize || $newPosition < 0) {
|
||||
return $return;
|
||||
}
|
||||
|
||||
$newFilePosition = floor($newPosition / $this->unencryptedBlockSize)
|
||||
* $this->util->getBlockSize() + $this->headerSize;
|
||||
|
||||
|
|
Loading…
Reference in a new issue