php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38989 Absolute path with slash at beginning doesn't work
Submitted: 2006-09-29 07:45 UTC Modified: 2006-10-05 08:06 UTC
From: info at xboot dot de Assigned: dmitry (profile)
Status: Closed Package: Filesystem function related
PHP Version: 5CVS-2006-09-29 (snap) OS: Windows 2003 SP1
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: info at xboot dot de
New email:
PHP Version: OS:

 

 [2006-09-29 07:45 UTC] info at xboot dot de
Description:
------------
System:
Win 2003 SP1
IIS 6
PHP 5.2.0RC5-dev (29.09.2006)

File operations with slash at the beginning (absolute path) don't work. It doesn't matter which kind of function i use. include(), fopen(), SPL-functions, ... don't work if i pass a filename with a slash at the beginning. If i add the drive letter it works correct.

The same script works fine with PHP 5.1.2.

Reproduce code:
---------------
<?php

echo $_SERVER['PHP_SELF'] . '<br />';

$handle = fopen($_SERVER['PHP_SELF'], "r");

// this is the same file, but it works:
// $handle = fopen("D:\Intranet\path.php", "r");

echo $handle;

?>

Expected result:
----------------
Result with PHP 5.1.2:

/intranet/path.php
Resource id #2

Actual result:
--------------
Result with PHP Version 5.2.0RC5-dev (29.09.2006):

/intranet/path.php

Warning: fopen(/intranet/path.php) [function.fopen]: failed to open stream: No such file or directory in D:\Intranet\path.php on line 5


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-09-29 08:33 UTC] info at xboot dot de
PHP runs as ISAPI
 [2006-10-04 14:36 UTC] RQuadling at GMail dot com
With the CLI version, if you are in the root of the drive when the script is run then the file is found.

<?php 
// C:\boot.ini
echo file_get_contents('/boot.ini');
// D:\system.pas
echo file_get_contents('/system.pas');
?>

If in C:\, then boot.ini is found. If in my C:\BATCH directory then it is not.

According to System Internals FileMon.exe, filtering boot.ini;system.pas results in ...

14:56:56	php.exe:2004	IRP_MJ_DIRECTORY_CONTROL	C:\BATCH\	NO SUCH FILE	FileBothDirectoryInformation: boot.ini	
14:56:56	php.exe:2004	IRP_MJ_CREATE 	C:\BATCH\boot.ini	NOT FOUND	Options: Open  Access: All	
14:56:56	php.exe:2004	IRP_MJ_DIRECTORY_CONTROL	C:\BATCH\	NO SUCH FILE	FileBothDirectoryInformation: system.pas	
14:56:56	php.exe:2004	IRP_MJ_CREATE 	C:\BATCH\system.pas	NOT FOUND	Options: Open  Access: All	

This removes the issue as relating to ISAPI only (i.e. it is not the webserver getting in the way).

Using php -n at the cli removes any issue with ini file settings.
 [2006-10-05 08:06 UTC] dmitry@php.net
Fixed in CVS HEAD and PHP_5_2.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 10 07:01:28 2024 UTC