php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72738 realpath() expands junction points
Submitted: 2016-08-02 19:31 UTC Modified: 2016-08-02 22:29 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: anrdaemon at freemail dot ru Assigned:
Status: Verified Package: Filesystem function related
PHP Version: 7.1.0beta1 OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: anrdaemon at freemail dot ru
New email:
PHP Version: OS:

 

 [2016-08-02 19:31 UTC] anrdaemon at freemail dot ru
Description:
------------
On Windows, realpath() expands the directory junction points.
According to an apparently authoritative assesment of pajoye@php.net in the https://bugs.php.net/bug.php?id=72642 , this shouldn't happen.

Test script:
---------------
<?php

$rootdir = substr(getenv('SystemRoot'), 0, 3);
$tmpdir = getenv('TEMP');
shell_exec("mklink /J \"{$rootdir}home\" \"{$rootdir}Users\"");
shell_exec("mklink /J \"{$tmpdir}\\test.dir\" \"{$rootdir}home\\Public\\Desktop\"");
$file = "{$tmpdir}\\test.dir\\desktop.ini";
$rfile1 = realpath($file);
$rfile2 = realpath($rfile1);
printf("orig.file name: %s\n", $file);
printf("realpath(name): %s (%s)\n", $rfile1, $file == $rfile1 ? 'Ok' : 'fail');
printf("THE real name:  %s (%s)\n", $rfile2, $file == $rfile2 ? 'Ok' : 'fail');

rmdir("{$rootdir}home");
rmdir("{$tmpdir}\\test.dir");


Expected result:
----------------
According to pajoye@php.net, expansion shouldn't happen, and all paths must be the same == the original path.

Actual result:
--------------
All paths are different. On each iteration, realpath() only expands a portion of nested junctions.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-08-02 22:29 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2016-08-02 22:29 UTC] cmb@php.net
I can confirm this behavior. Obviously, the invariant

  realpath(realpath($x)) == realpath($x)

does not hold in this case.
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC