Bug #16483 Updated: file_exists() results in stat() error

From: Date: Mon, 08 Apr 2002 06:21:06 +0000
Subject: Bug #16483 Updated: file_exists() results in stat() error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-4308@lists.php.net to get a copy of this message
ID: 16483 Updated by: derick@php.net Reported By: don@blacksun.org -Status: Open +Status: Feedback Bug Type: Filesystem function related Operating System: FreeBSD 4.5-STABLE PHP Version: 4.1.2 New Comment: Please verify that this bug is fixed in php4.2.0rc2. You can find it at www.php.net/~derick/ Derick Previous Comments: ------------------------------------------------------------------------ [2002-04-08 01:54:57] don@blacksun.org Here is the error: Warning: stat failed for index/nothing (errno=20 - Not a directory) in /usr/local/www/htdocs/support/index.php "index" is a regular file. A file_exists("index/nothing"); returns a stat error. -Don ------------------------------------------------------------------------ [2002-04-08 01:52:33] don@blacksun.org If you try to stat a file that appears to be in a directory, and that directory is actually a regular file instead, file_exists() throws a stat error instead of just returning false. Needless to say this makes checking user input a lot more difficult. I am forced to check the entire path to see if each part is a directory before finally checking the last part to see whether it exists. file_exists() is a function and should either return true or false. If the file exists it should return true. If it does not (for _whatever_ reason) it should return false. Side effects like a stat error are unwanted, and can provide useful information to someone trying to attack the site. -Don ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=16483&edit=1

« previous php.bugs (#4308) next »