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

Prevent race condition (updated for style rules) #27

Merged
merged 1 commit into from
Mar 14, 2018
Merged

Conversation

nk53
Copy link
Contributor

@nk53 nk53 commented Mar 13, 2018

When I test this on my machine, the last two processes to read a chunk will occasionally both attempt to write the combined file.

Cakephp can use locking to ensure no more than one process writes to a file at a time, however it does not guarantee that only one process writes to a file at all. For this, we need to open the file with the O_EXCL flag (x in PHP).

This pull request ensures only one process will write to destFile.

@dilab dilab merged commit de7dcc8 into dilab:master Mar 14, 2018
@dilab
Copy link
Owner

dilab commented Mar 14, 2018

thanks!

@nk53
Copy link
Contributor Author

nk53 commented Mar 14, 2018

OK I have to apologize, because I apparently made a typo ("9" where a "(" should be, on line 287).

@dilab
Copy link
Owner

dilab commented Mar 14, 2018

@nk53
can you create another PR to fix it?

@williamdes
Copy link
Contributor

This fix prevents the vulnerability #34 to overwrite files

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

Successfully merging this pull request may close these issues.

None yet

3 participants