#25583 [Asn->Csd]: Incorrect handling of absolute path without drive.
| From: | iliaa@php.net | Date: | Sat, 20 Sep 2003 01:38:11 +0000 |
| Subject: | #25583 [Asn->Csd]: Incorrect handling of absolute path without drive. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-47850@lists.php.net to get a copy of this message | ||
ID: 25583
Updated by: iliaa@php.net
Reported By: d dot stogov at turck dot spb dot eu
-Status: Assigned
+Status: Closed
Bug Type: Directory function related
Operating System: Windows
PHP Version: 4.3.3
Assigned To: iliaa
New Comment:
This bug has been fixed in CVS.
In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2003-09-18 04:05:37] d dot stogov at turck dot spb dot eu
Description:
------------
This BUG is Windows releated. PHP thinks what filepathes started form
one slash are relative. The problem comes from IS_ABSOLUTE_PATH definw
which is defined in file "TSRM/tsrm_virtual_cwd.h" line 64.
The original source is
#define IS_ABSOLUTE_PATH(path, len) \
(len >= 2 && ((isalpha(path[0]) && path[1] == ':') ||
(IS_SLASH(path[0]) && IS_SLASH(path[1]))))
but I think it must be changed to
#define IS_ABSOLUTE_PATH(path, len) \
((len >= 2 && isalpha(path[0]) && path[1] == ':') || \
(len >= 1 && IS_SLASH(path[0]) && IS_SLASH(path[1])))
I demonstrate the BUG of the glob() function, but it can occur in any
place where IS_ABSOLUTE_PATH is used.
Reproduce code:
---------------
<?php
function remove_drive($file) {
return substr($file,2);
}
if (substr(PHP_OS,0,3) == WIN) {
$drive = substr(getcwd(),0,2);
$a1 = glob("/*");
$a2 = array_map("remove_drive",glob($drive."/*"));
if ($a1==$a2) {
echo "ok";
} else {
echo "fail";
}
} else {
echo "ok";
}
?>
Expected result:
----------------
ok
Actual result:
--------------
fail
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=25583&edit=1