From 54a15a80011e50e7b7b9cf9c946c5bd5e82df42b Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 20 Mar 2014 15:35:01 +0100 Subject: [PATCH 1/2] Use streams when generating hashes of remote files --- lib/private/files/storage/common.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/private/files/storage/common.php b/lib/private/files/storage/common.php index 2b697141515..05e031b37ad 100644 --- a/lib/private/files/storage/common.php +++ b/lib/private/files/storage/common.php @@ -159,9 +159,11 @@ abstract class Common implements \OC\Files\Storage\Storage { } public function hash($type, $path, $raw = false) { - $tmpFile = $this->getLocalFile($path); - $hash = hash_file($type, $tmpFile, $raw); - return $hash; + $fh = $this->fopen($path, 'r'); + $ctx = hash_init($type); + hash_update_stream($ctx, $fh); + fclose($fh); + return hash_final($ctx, $raw); } public function search($query) { From 1c7a71ca779af16059dd00dbe3dd79097c556ad4 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 20 Mar 2014 16:45:24 +0100 Subject: [PATCH 2/2] use binary safe read --- lib/private/files/storage/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/files/storage/common.php b/lib/private/files/storage/common.php index 05e031b37ad..9af3a398c1c 100644 --- a/lib/private/files/storage/common.php +++ b/lib/private/files/storage/common.php @@ -159,7 +159,7 @@ abstract class Common implements \OC\Files\Storage\Storage { } public function hash($type, $path, $raw = false) { - $fh = $this->fopen($path, 'r'); + $fh = $this->fopen($path, 'rb'); $ctx = hash_init($type); hash_update_stream($ctx, $fh); fclose($fh);