Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid fread on directories and unencrypted files #24966

Merged
merged 7 commits into from
Apr 6, 2021

Conversation

jknockaert
Copy link
Contributor

@jknockaert jknockaert commented Jan 5, 2021

Reworking the logic in order to first check the filecache and only then reading the fileheader.
This in order to solve #21578.
Signed-off-by: Jasper Knockaert jasper@knockaert.nl

Reworking the logic in order to first check the filecache and only then reading the fileheader.
This in order to solve #21578.
@jknockaert
Copy link
Contributor Author

@nextcloud/encryption Pls review. Also check the discussion of the issue I posted in #21578. That said, I didn't yet find out why this function is evaluated very often for keyfiles.

@jknockaert
Copy link
Contributor Author

Signed-off-by: Jasper Knockaert jasper@knockaert.nl

@jknockaert
Copy link
Contributor Author

Can anyone help with the testing? It is my understanding that in the tests the call to the cache was never evaluated, so I guess that should somewhere be caught now that it comes first.

@jknockaert
Copy link
Contributor Author

OK, with all checks passed now I think this one is ready for review. As for the getHeader function I'm pretty sure I fully understand the code and I think my implementation is fine; but still then I don't have a full overview of all use cases of this function so I may miss out on a corner case. As for the tests I somehow got it working; not sure though if I fully understand what I did here. I couldn't do any meaningful benchmarking so I can't say much on the impact of the changes introduced. I wouldn't expect it to matter much.

@ghost
Copy link

ghost commented Jan 7, 2021

@jknockaert I applied the below fix and im not getting the errors anymore

image

@RedKage
Copy link

RedKage commented Jan 16, 2021

I dont know what this is doing, nor am I a nextcloud maintainer.
However I think that IF can be simplified and be made more readable with

    if (!isset($result[Util::HEADER_ENCRYPTION_MODULE_KEY] && (!empty($result) || $exists)) {
        $result[Util::HEADER_ENCRYPTION_MODULE_KEY] = 'OC_DEFAULT_MODULE';
    }

Jasper Knockaert added 3 commits January 16, 2021 14:33
Signed-off-by: Jasper Knockaert jasper@knockaert.nl
@jknockaert
Copy link
Contributor Author

@RedKage Thanks; fixed.

@jknockaert
Copy link
Contributor Author

@ChristophWurst Any suggestion who to invite for a review?

@jknockaert
Copy link
Contributor Author

@nextcloud/encryption Can anyone review? This is a fairly minor patch that fixes errors with php7.4. It would be good to have it included in the next point release of nextcloud.

@moverduinsecov
Copy link

Have applied changes manually, and so far everything looks fine.

@jknockaert
Copy link
Contributor Author

Can anyone review? This is a minor (and straightforward) patch that fixes errors with php7.4. It would be good to have it included in the next point release of nextcloud.

@ghost

This comment has been minimized.

@vitormattos
Copy link
Contributor

@icewind1991

I believe that this should be fine, but I haven't looked into the encryption logic for a long time

If the test passes, what's wrong? :-)

@vitormattos vitormattos self-requested a review April 5, 2021 02:29
Copy link
Contributor

@vitormattos vitormattos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to be ok, there seems to be no need to create new test scenarios.

@LukasReschke LukasReschke merged commit 4b4971a into master Apr 6, 2021
@LukasReschke LukasReschke deleted the jknockaert-patch-1 branch April 6, 2021 11:45
@welcome
Copy link

welcome bot commented Apr 6, 2021

Thanks for your first pull request and welcome to the community! Feel free to keep them coming! If you are looking for issues to tackle then have a look at this selection: https://github.com/nextcloud/server/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22

@jknockaert
Copy link
Contributor Author

Thanks @vitormattos and @icewind1991 for the reviews.

@ghost

This comment has been minimized.

@vitormattos
Copy link
Contributor

It is in the same class but does not seem to be related to this pull request.

Looking at the log quickly, without a thorough analysis, the method changed in this pull request is not in the callstack of the log you posted.

@ghost

This comment has been minimized.

@vitormattos
Copy link
Contributor

I suggest sending a new pull request solving this problem :)

The solution is already described in the log, it is necessary to implement, check the impacts, review the unit tests to ensure they are ok and send the pull request.

@ghost
Copy link

ghost commented Apr 8, 2021

I just did! i tagged you in it so maybe we can have someone look at it quicker :)

@vitormattos
Copy link
Contributor

You have opened an issue. Submit the pull request with the solution. The correction is simple, but it is necessary to check the impacts well.

@ghost
Copy link

ghost commented Apr 8, 2021

@vitormattos i would not know the solutions i don't code. maybe @jknockaert knows it but i dont

@jknockaert
Copy link
Contributor Author

@axheli Pls tag me. I may have time to have a look at it over the weekend.
That said, I think the filesystem code is in some need for a more thorough review and possibly rewrite.

@vitormattos
Copy link
Contributor

I just did! i tagged you in it so maybe we can have someone look at it quicker :)

@jknockaert #26464

@ghost
Copy link

ghost commented Apr 8, 2021

@jknockaert Thank you so much :)

@ghost
Copy link

ghost commented May 28, 2021

Still an issue on Nextcloud 21.0.2 @LukasReschke can we please add this fix ?

@solracsf
Copy link
Member

solracsf commented Jun 6, 2021

/backport to stable21

@solracsf
Copy link
Member

solracsf commented Jun 6, 2021

/backport to stable20

@solracsf
Copy link
Member

solracsf commented Jun 6, 2021

/backport to stable19

@ghost
Copy link

ghost commented Jul 2, 2021

Hello everyone is anybody willing to add this fix to the Next release 21.0.4 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants