Bug #79806 [PATCH]: realpath() erroneously resolves link to link

From: Date: Wed, 15 Jul 2020 16:39:13 +0000
Subject: Bug #79806 [PATCH]: realpath() erroneously resolves link to link
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-228071@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79806&edit=1

 ID:                 79806
 Patch added by:     cmb@php.net
 Reported by:        cmb@php.net
 Summary:            realpath() erroneously resolves link to link
 Status:             Assigned
 Type:               Bug
 Package:            Filesystem function related
 Operating System:   Windows NTS
 PHP Version:        7.3
 Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

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


Previous Comments:
------------------------------------------------------------------------
[2020-07-07 15:19:45] 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"


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=79806&edit=1


Thread (5 messages)

« previous php.bugs (#228071) next »