#32627 [Csd->Opn]: realpath fails to return FALSE if last path component does not exist

From: Date: Sun, 08 May 2005 12:42:05 +0000
Subject: #32627 [Csd->Opn]: realpath fails to return FALSE if last path component does not exist
References: 1  Groups: php.doc 
Request: Send a blank email to phpdoc+get-969368208@lists.php.net to get a copy of this message
ID: 32627 Updated by: alindeman@php.net Reported By: alan dot harder at sun dot com -Status: Closed +Status: Open -Bug Type: Filesystem function related +Bug Type: Documentation problem Operating System: FreeBSD 4.11-STABLE PHP Version: 4.3.10 Previous Comments: ------------------------------------------------------------------------ [2005-04-07 23:44:31] sesser@php.net This is not fixed at all... This is a documentation bug... realpath() uses the underlying system realpath() { unless you run it with the hardening-patch } On linux/glibc realpath() will return failure if the last component does not exist. On BSD realpath() will not return failure if only the last component does not exist. ------------------------------------------------------------------------ [2005-04-07 21:42:39] alan dot harder at sun dot com thanks for the response. by "latest" do you mean php5? as shown in this bug description I tested with today's stable 4.3.x build in addition to 4.3.10 where i found the problem. ------------------------------------------------------------------------ [2005-04-07 21:04:46] sniper@php.net Thank you for your bug report. This issue has already been fixed in the latest released version of PHP, which you can download at http://www.php.net/downloads.php ------------------------------------------------------------------------ [2005-04-07 18:23:45] alan dot harder at sun dot com Description: ------------ I have found that realpath() returns a path when it should return FALSE if only the last path component in the given string does not exist. Tested on php 4.3.10 and php4-STABLE-200504071438. Both tests and phpinfo can be viewed at http://realpath.moshpit.org/ Reproduce code: --------------- $x = realpath('/bad/path'); var_dump($x); $x = realpath('/badpath'); var_dump($x); $x = realpath('/tmp/badpath'); var_dump($x); View tests at http://realpath.moshpit.org/ Expected result: ---------------- FALSE for all three tests. Actual result: -------------- The first one works (gets FALSE), the other two return the path when they should return FALSE (assuming /tmp is valid). ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=32627&edit=1

« previous php.doc (#969368208) next »