Repository navigation
Return whole file if range request cannot be granted due to encryption - #10422
Conversation
Whenenver range headers are set and encryption is enabled, it is not possible to automatically fseek() to the proper position. To avoid returning corrupt/invalid data or causing a decryption error, the range headers are stripped so that the SabreDAV code in httpGet() returns the whole file.
|
Note: this is currently only for the encryption case. |
|
External storage seems to be unaffected by this issue, see #10383 (comment) |
|
🚀 Test Passed. 🚀 |
|
To test this, try curl with a range request with and without encryption: When encryption is disabled you should get 100 bytes and also a |
|
tested, works... code looks good too 👍 |
Care to explain why that is the case? E.g. there is https://github.com/owncloud/core/blob/master/apps/files_encryption/lib/stream.php#L224 |
|
@bantu I think fseek for encryption never worked properly. Someone submit a PR to make it seekable #8390 Also, even if we make encryption's fseek return false to signal an error or "unsupported", SabreDAV will ignore the error. This PR here is needed in the short term and is intend for backport. The PR above could be used in OC 8 for proper seeking support. |
|
A new inspection was created. |
|
@bantu encrypted files are bigger than unencrypted files. |
|
@bantu @icewind1991 please review, I'd like to get this in 7.0.2 for tomorrow. |
|
@owncloud-bot retest this please |
|
looks good 👍 |
|
IT IS ALIVE! |
|
YES - I AM! |
|
🚀 Test Passed. 🚀 |
…tsupported Return whole file if range request cannot be granted due to encryption
|
@karlitschek backport to stable7 ? (fixes corrupted files with HTTP range requests + encryption) |
|
Maybe even stable6 :-/ |
|
I'm not sure about stable6 as we had another SabreDAV version, might need further testing. |
|
Please backport if this is properly tested. @dragotin can you help? |
|
Just did a manual test as follows:
I'll do the same test without the fix to confirm that it breaks without it. |
|
@dragotin is it possible to add download resuming tests to your magical automated test suites ? |
|
O.K. Fine with me than. I only wanted to make sure that we are over careful with last minute backports like that that could affect syncing. |
|
Yes of course that makes sense. |
|
I'll push the backport once I'm done with testing. |
|
Negative test confirmed: resuming gives the expected 500 internal server error. |
|
Second run of the test with the same files and random unplugging worked as well: MD5 match. Backported to stable7 as c6e87ac |
|
And the last test without encryption: I observed the file being resumed properly multiple times by the sync client and the resulting md5 still matches. |
|
@PVince81 Example of a corrupted file (original file at the left side, first 398 lines at the right side are corrupted): Does the solution for the current issue also solve the problem of encrypted files getting corrupted during the upload? Uploaded by OC client v1.6.2 |
|
@VincentvgNn I expect this to also fix corrupted files because in your case it was also about resuming encrypted files. Can you try with OC 7.0.2 RC 1 which has the fix ? |
|
@PVince81 |
|
@PVince81 Did I discover a new issue to be reported? |
|
@VincentvgNn hmmm the fix is only for the webdav download interface, not web interface. If you did the following:
and still get corrupted files, then you probably discovered another issue 😦 |
|
@PVince81 |
|
Okay got it, so it's possibly a corruption at upload time, which is not covered by the fix above. |
|
@PVince81 |
|
Whichever repo as we don't know about the issue yet. On a second thought it is more likely to be a core/server issue since that's where encryption is happening. |
|
I didn't notice this PR until now. I submitted PR #8390. @PVince81 merging it to OC 8 seems like a good idea to me, but #8390 is only tested on OC 6 so far. I will follow up in that PR. |

Whenenver range headers are set and encryption is enabled, it is not
possible to automatically fseek() to the proper position.
To avoid returning corrupt/invalid data or causing a decryption error,
the range headers are stripped so that the SabreDAV code in httpGet()
returns the whole file.
Fixes #10383
Please review @DeepDiver1975 @icewind1991 @schiesbn @guruz