summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2016-02-23 17:53:19 +0100
committerLukas Reschke <lukas@owncloud.com>2016-02-25 09:40:30 +0100
commit3b5ddb417c9811a6a57e2af0f379e088e71e84a4 (patch)
tree62c623b64740edc3b186d76f0d941da3d51b4b64 /apps
parent32f4bea0ae174487fd5a58e2c9eeb6e567d1ff91 (diff)
downloadnextcloud-server-3b5ddb417c9811a6a57e2af0f379e088e71e84a4.tar.gz
nextcloud-server-3b5ddb417c9811a6a57e2af0f379e088e71e84a4.zip
Copy into local file
Using the Guzzle stream directly here will only return 1739 characters for `fread` instead of all data. This leads to the problem that the stream is read incorrectly and thus the data cannot be properly decrypted => :bomb: This approach copies the data into a local temporary file, as done before in all stable releases as well as other storage connectors. While this approach will load the whole file into memory, this is already was has happened before in any stable release as well. See https://github.com/owncloud/core/commit/d608c37c90c308d0518d854de908ec4be5f462dc for the breaking change. To test this enable Google Drive as external storage and upload some files with encryption enabled. Reading the file should fail now. Fixes https://github.com/owncloud/core/issues/22590
Diffstat (limited to 'apps')
-rw-r--r--apps/files_external/lib/google.php8
1 files changed, 5 insertions, 3 deletions
diff --git a/apps/files_external/lib/google.php b/apps/files_external/lib/google.php
index ee7a7383615..982fa6bb48f 100644
--- a/apps/files_external/lib/google.php
+++ b/apps/files_external/lib/google.php
@@ -33,6 +33,7 @@
namespace OC\Files\Storage;
+use GuzzleHttp\Exception\RequestException;
use Icewind\Streams\IteratorDirectory;
set_include_path(get_include_path().PATH_SEPARATOR.
@@ -439,9 +440,10 @@ class Google extends \OC\Files\Storage\Common {
// the library's service doesn't support streaming, so we use Guzzle instead
$client = \OC::$server->getHTTPClientService()->newClient();
try {
- $response = $client->get($downloadUrl, [
+ $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext);
+ $client->get($downloadUrl, [
'headers' => $httpRequest->getRequestHeaders(),
- 'stream' => true
+ 'save_to' => $tmpFile,
]);
} catch (RequestException $e) {
if ($e->getResponse()->getStatusCode() === 404) {
@@ -451,7 +453,7 @@ class Google extends \OC\Files\Storage\Common {
}
}
- return $response->getBody();
+ return fopen($tmpFile, 'r');
}
}
return false;