summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorjknockaert <jasper@knockaert.nl>2015-04-30 17:10:18 +0200
committerjknockaert <jasper@knockaert.nl>2015-04-30 17:10:18 +0200
commitf5415653fd975b41e0bc27fca8b0666288fc5eef (patch)
tree4f6af3595fd2c8603944da134728b53f4cd79d70 /lib
parent41d7870d7b8aa1b635fd1d2d589322160bb46d31 (diff)
downloadnextcloud-server-f5415653fd975b41e0bc27fca8b0666288fc5eef.tar.gz
nextcloud-server-f5415653fd975b41e0bc27fca8b0666288fc5eef.zip
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/private/files/stream/encryption.php16
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/private/files/stream/encryption.php b/lib/private/files/stream/encryption.php
index 0262405f367..e423868d82b 100644
--- a/lib/private/files/stream/encryption.php
+++ b/lib/private/files/stream/encryption.php
@@ -356,24 +356,22 @@ class Encryption extends Wrapper {
switch ($whence) {
case SEEK_SET:
- if ($offset < $this->unencryptedSize && $offset >= 0) {
- $newPosition = $offset;
- }
+ $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;
- }
+ $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;