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

realpath returns wrong results for files > 2GB #1

Closed
vhalasu opened this issue Mar 17, 2013 · 6 comments
Closed

realpath returns wrong results for files > 2GB #1

vhalasu opened this issue Mar 17, 2013 · 6 comments
Labels

Comments

@vhalasu
Copy link

vhalasu commented Mar 17, 2013

Env.: PHP 5.3.5, 64bit machine with 32bit Suse linux 11.4
Tried with 670MB, 2.6GB, 4.6GB and 6.8GB files and symlinks to them.

For regular files the behavior is consistently wrong: if file size is over PHP_INT_MAX, realpath return FALSE. Results for symlinks are rather unsure: if you call clearstatcache before realpath, you'll get the same as with regular files. Without clearstatcache however, realpath for first time return FALSE, then after refreshing the page it starts returning resolved symlink (= absolute path to file). If you don't refresh the page for approx 30sec, you're back on the beginning - first FALSE, then correct path.

This affects mainly the sizeCurl method - if realpath (that is, this->$path after calling absolutizePath) returns FALSE, then the address resolves to file:// and the size of current directory is returned.

The same applied for regular files on FAT32 partition (no symlinks of course and only the two smallest).

Found some realpath replacement here: http://stackoverflow.com/questions/4049856/replace-phps-realpath , but didn't try it yet. Personally I'm using absolute paths whenever possible.

@jkuchar
Copy link
Owner

jkuchar commented Mar 18, 2013

I'll check it on Linux Mint. Windows Server 2008/2003 not affected.

@vhalasu
Copy link
Author

vhalasu commented Mar 31, 2013

This PHP bug seems related (to #3 as well): https://bugs.php.net/bug.php?id=27792

@bantu
Copy link

bantu commented Oct 16, 2013

Checking the return value of realpath() would be a good start.

@jkuchar
Copy link
Owner

jkuchar commented Oct 21, 2013

Changed mechanism of setting path. Now throws exception. (branch: master)

@jkuchar
Copy link
Owner

jkuchar commented Oct 30, 2013

Idea: if file:// is resolved to current directory, does it resolve relative paths?

@jkuchar
Copy link
Owner

jkuchar commented Dec 31, 2015

Closed due to innactivity. Reopen anytime if it is still relevant.

@jkuchar jkuchar closed this as completed Dec 31, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants