Skip to content

Always check variable type before using readdir to avoid surprises - #4719

Merged
DeepDiver1975 merged 2 commits into
masterfrom
port_4701_master
Sep 12, 2013
Merged

DeepDiver1975 merged 2 commits into
masterfrom
port_4701_master

Conversation

@blizzz

@blizzz blizzz commented Sep 4, 2013

Copy link
Copy Markdown
Contributor

Port of #4701, with few adjustments according to master.

@bartv2 @icewind1991 @karlitschek or others please.

@karlitschek

Copy link
Copy Markdown
Contributor

👍

@ghost

ghost commented Sep 4, 2013

Copy link
Copy Markdown

@bantu

bantu commented Sep 4, 2013

Copy link
Copy Markdown

Hmm, aren't there iterators that could be used instead of the old-fashioned readdir stuff?

@blizzz

blizzz commented Sep 4, 2013

Copy link
Copy Markdown
Contributor Author

Like http://php.net/manual/en/class.directoryiterator.php? Would be certainly more modern and would probably fix the issues, too. But I'd prefer to get this as is into master to make sure the bugs fixed in #4701 are also dealt with on master. Then it may be switched to Iterators, if it really gives us a benefit.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

space

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You are correct.

@bantu

bantu commented Sep 4, 2013

Copy link
Copy Markdown

@blizzz Yes.

@blizzz

blizzz commented Sep 4, 2013

Copy link
Copy Markdown
Contributor Author

@bantu so, do you give me a thumb? 🐱

@DeepDiver1975

Copy link
Copy Markdown
Contributor

@blizzz @schiesbn there is one readdir in \OCA\Encryption\Util::findEncFiles() where no is_resource() call has been inserted - can you please double check? THX

@DeepDiver1975

Copy link
Copy Markdown
Contributor

\OC_Mount_Config::getCertificates() as well

@DeepDiver1975

Copy link
Copy Markdown
Contributor

OC\Files\Storage\Shared::filemtime

@DeepDiver1975

Copy link
Copy Markdown
Contributor

\OC_Helper:chmodr()
\OC_Helper:cleanTmpNoClean()
\OC\Files\Storage\MappedLocal::opendir()
\OC_MIgration_Content:addDir()

@icewind1991 maybe you can help out here as well - thx

@blizzz

blizzz commented Sep 5, 2013

Copy link
Copy Markdown
Contributor Author

Your're right, I only checked the changes from c5402f4

@blizzz

blizzz commented Sep 5, 2013

Copy link
Copy Markdown
Contributor Author

Hint: to hide the whitespace changes in the util.php add "?w=0" to the url, or click https://github.com/owncloud/core/pull/4719/files?w=0

@ghost

ghost commented Sep 5, 2013

Copy link
Copy Markdown

@schiessle

Copy link
Copy Markdown
Contributor

there is one readdir in \OCA\Encryption\Util::findEncFiles() where no is_resource() call has been inserted - can you please double check? THX

opendir() happens in the if statement which should be equivalent to the is_resource() check, see

&& $handle = $this->view->opendir($directory)

Now we check twice if opendir() was successful. I would suggest to either remove the is_resource check again or maybe better for readability, move $handle = $this->view->opendir($directory) out of the if statement and keep the is_resource check.

@DeepDiver1975

Copy link
Copy Markdown
Contributor

👍

@DeepDiver1975

Copy link
Copy Markdown
Contributor

Thanks for fixing this!

DeepDiver1975 added a commit that referenced this pull request Sep 12, 2013
Always check variable type before using readdir to avoid surprises
@DeepDiver1975
DeepDiver1975 merged commit d5ddbfb into master Sep 12, 2013
@DeepDiver1975
DeepDiver1975 deleted the port_4701_master branch September 12, 2013 22:45
@lock lock Bot locked as resolved and limited conversation to collaborators Aug 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants