diff options
author | Morris Jobke <hey@morrisjobke.de> | 2016-04-04 16:48:09 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2016-04-04 16:48:09 +0200 |
commit | 6ecd1d9e86dc3f2b70da1071a13f661702627624 (patch) | |
tree | 6387d3f090d16f82342751e1a471f0abdab24a5d /lib/private/files/storage/local.php | |
parent | f6cea3c9c436142110504ba76320d57ca7899b27 (diff) | |
download | nextcloud-server-6ecd1d9e86dc3f2b70da1071a13f661702627624.tar.gz nextcloud-server-6ecd1d9e86dc3f2b70da1071a13f661702627624.zip |
Fix PHP memory leak in file_get_contents()
* ref https://bugs.php.net/bug.php?id=61961
* ref https://github.com/owncloud/core/issues/20261#issuecomment-180000256
* code is based on the proposal of @chriseqipe
* fixes #20261
Diffstat (limited to 'lib/private/files/storage/local.php')
-rw-r--r-- | lib/private/files/storage/local.php | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/private/files/storage/local.php b/lib/private/files/storage/local.php index f6f5a8cc130..b6d0ec3fb34 100644 --- a/lib/private/files/storage/local.php +++ b/lib/private/files/storage/local.php @@ -176,7 +176,12 @@ class Local extends \OC\Files\Storage\Common { } public function file_get_contents($path) { - return file_get_contents($this->getSourcePath($path)); + // file_get_contents() has a memory leak: https://bugs.php.net/bug.php?id=61961 + $filename = $this->getSourcePath($path); + $handle = fopen($filename,'rb'); + $content = fread($handle, filesize($filename)); + fclose($handle); + return $content; } public function file_put_contents($path, $data) { |