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 => 💣
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 d608c37c90
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
This commit is contained in:
parent
32f4bea0ae
commit
3b5ddb417c
1 changed files with 5 additions and 3 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue