php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79806 realpath() erroneously resolves link to link
Submitted: 2020-07-07 15:19 UTC Modified: 2020-07-28 12:05 UTC
From: cmb@php.net Assigned: cmb (profile)
Status: Closed Package: Filesystem function related
PHP Version: 7.3 OS: Windows NTS
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: cmb@php.net
New email:
PHP Version: OS:

 

 [2020-07-07 15:19 UTC] cmb@php.net
Description:
------------
On Windows realpath() only resolves the first level (soft or hard)
link, but does not go further.  This does neither match the
behavior on Linux (as far as I know), not the documentation which
states:

| The resulting path will have no symbolic link, […]



Test script:
---------------
<?php
touch(__DIR__ . '/link.txt');
symlink(__DIR__ . '/link.txt', __DIR__ . '/link1.lnk');
symlink(__DIR__ . '/link1.lnk', __DIR__ . '/link2.lnk');

var_dump(substr(realpath(__DIR__ . '/link2.lnk'), strlen(__DIR__)));
?>

Expected result:
----------------
string(9) "\link.txt"

Actual result:
--------------
string(10) "\link1.lnk"

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-07-07 15:19 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2020-07-15 16:38 UTC] cmb@php.net
-PHP Version: 7.4.7 +PHP Version: 7.3
 [2020-07-15 16:39 UTC] cmb@php.net
The following pull request has been associated:

Patch Name: Fix #79806: realpath() erroneously resolves link to link
On GitHub:  https://github.com/php/php-src/pull/5861
Patch:      https://github.com/php/php-src/pull/5861.patch
 [2020-07-27 13:12 UTC] cmb@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=d5b59b4303642adac91df2c93969a72bc0f5fa7d
Log: Fix #79806: realpath() erroneously resolves link to link
 [2020-07-27 13:12 UTC] cmb@php.net
-Status: Assigned +Status: Closed
 [2020-07-27 15:54 UTC] cmb@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=1aeff522b8e5ee77b9ae91bab59699db4dfc2c7e
Log: Revert &quot;Fix #79806: realpath() erroneously resolves link to link&quot;
 [2020-07-27 15:54 UTC] cmb@php.net
-Status: Closed +Status: Re-Opened
 [2020-07-28 12:05 UTC] cmb@php.net
-Status: Re-Opened +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 11:01:29 2024 UTC