diff options
author | Georg Ehrke <dev@georgswebsite.de> | 2012-04-21 23:21:50 +0200 |
---|---|---|
committer | Georg Ehrke <dev@georgswebsite.de> | 2012-04-21 23:21:50 +0200 |
commit | 0918fc7d9156f3846a19b673db5b01422a59c506 (patch) | |
tree | 131188252fd42c4f3c9673975adafa24783c632f /apps/files_encryption/lib/cryptstream.php | |
parent | 77cefdedb86de65e69f470c8b6a1b03bb001966e (diff) | |
parent | 74e540271122222f650bbbfaeaac310b0e592674 (diff) | |
download | nextcloud-server-0918fc7d9156f3846a19b673db5b01422a59c506.tar.gz nextcloud-server-0918fc7d9156f3846a19b673db5b01422a59c506.zip |
fix merge conflicts
Diffstat (limited to 'apps/files_encryption/lib/cryptstream.php')
-rw-r--r-- | apps/files_encryption/lib/cryptstream.php | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/apps/files_encryption/lib/cryptstream.php b/apps/files_encryption/lib/cryptstream.php index 86583096f1d..21fa38e4b59 100644 --- a/apps/files_encryption/lib/cryptstream.php +++ b/apps/files_encryption/lib/cryptstream.php @@ -64,29 +64,19 @@ class OC_CryptStream{ } public function stream_read($count){ - $pos=0; - $currentPos=ftell($this->source); - $offset=$currentPos%8192; - $result=''; - if($offset>0){ - if($this->meta['seekable']){ - fseek($this->source,-$offset,SEEK_CUR);//if seeking isnt supported the internal read buffer will be used - }else{ - $pos=strlen($this->readBuffer); - $result=$this->readBuffer; - } + //$count will always be 8192 https://bugs.php.net/bug.php?id=21641 + //This makes this function a lot simpler but will breake everything the moment it's fixed + if($count!=8192){ + OC_Log::write('files_encryption','php bug 21641 no longer holds, decryption will not work',OC_Log::FATAL); + die(); } - while($count>$pos){ - $data=fread($this->source,8192); - $pos+=8192; - if(strlen($data)){ - $result.=OC_Crypt::decrypt($data); - } - } - if(!$this->meta['seekable']){ - $this->readBuffer=substr($result,$count); + $data=fread($this->source,8192); + if(strlen($data)){ + $result=OC_Crypt::decrypt($data); + }else{ + $result=''; } - return substr($result,0,$count); + return $result; } public function stream_write($data){ @@ -107,8 +97,10 @@ class OC_CryptStream{ $oldPos=ftell($this->source); $encryptedBlock=fread($this->source,8192); fseek($this->source,$oldPos); - $block=OC_Crypt::decrypt($encryptedBlock); - $data.=substr($block,strlen($data)); + if($encryptedBlock){ + $block=OC_Crypt::decrypt($encryptedBlock); + $data.=substr($block,strlen($data)); + } } $encrypted=OC_Crypt::encrypt(substr($data,0,8192)); fwrite($this->source,$encrypted); |