php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42038 realpath does not resolve symbolic link
Submitted: 2007-07-18 17:16 UTC Modified: 2008-08-26 23:02 UTC
Votes:2
Avg. Score:3.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (50.0%)
From: kraghuba at in dot ibm dot com Assigned: fb-req-jani (profile)
Status: Not a bug Package: Filesystem function related
PHP Version: 5CVS-2007-07-18 (snap) OS: MacOSX, FreeBSD
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: kraghuba at in dot ibm dot com
New email:
PHP Version: OS:

 

 [2007-07-18 17:16 UTC] kraghuba at in dot ibm dot com
Description:
------------
realpath() doesn't resolve symlink and returns the link file name when input path is a link path.

As per the documentation at http://in.php.net/manual/en/function.realpath.php, The resulting path will have no symbolic link, '/./' or '/../' components.

Applicable to php5.2.4 only on MacOS X.

Please check testcase symlink_link_linkinfo_is_link_variation6.phpt.


Reproduce code:
---------------
<?php
$file_path = dirname(__FILE__);
$filename = "$file_path/file.tmp";
$linkname = "$file_path/link.tmp";

$fp = fopen($filename, "w");
fclose($fp);

symlink($filename, $linkname); 
var_dump( realpath($linkname) );

unlink($linkname);
unlink($filename);
?>

Expected result:
----------------
string(%d) "%s/file.tmp"

Actual result:
--------------
string(%d) "%s/link.tmp"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-07-19 03:21 UTC] kraghuba at in dot ibm dot com
The reference to testcase symlink_link_linkinfo_is_link_variation6.phpt is wrong. The write testcases to check are :
ext/standard/tests/file/readlink_realpath_basic1.phpt
ext/standard/tests/file/readlink_realpath_variation1.phpt
ext/standard/tests/file/readlink_realpath_variation2.phpt

The similar failure is also noticed on FreeBSD.
(FreeBSD - FreeBSD lindsay.php.is 6.2-STABLE FreeBSD 6.2-STABLE #1: Thu Jun 28 22:12:54 CEST 2007 )

MACOSX details:
Darwin - Darwin thought 8.10.1 Darwin Kernel Version 8.10.1: Wed May 23 16:33:00 PDT 2007; root:xnu-792.22.5~1/RELEASE_I386 i386
 [2008-08-12 08:54 UTC] jani@php.net
I'm guessing this should be fixed in PHP_5_3 and HEAD by the commit by Dmitry?
 [2008-08-18 04:34 UTC] kraghuba at in dot ibm dot com
Hi Jani,

I do not MacOSX/FreeBSD system to verify this. If you know someone who has, pls request for verfication. 

PS: When i raised this defect ,i used test run report sent by others over the php-qa list.

with Regards,
Raghubansh
 [2008-08-26 23:02 UTC] jani@php.net
Don't open bug reports in behalf of anyone..
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 06 11:02:27 2025 UTC