php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42364 Crash when using getRealPath with DirectoryIterator
Submitted: 2007-08-21 17:15 UTC Modified: 2007-08-21 22:47 UTC
From: kfou at free dot fr Assigned:
Status: Closed Package: Reproducible crash
PHP Version: 5.2.4RC3-dev OS: Windows and Linux
Private report: No CVE-ID: None
 [2007-08-21 17:15 UTC] kfou at free dot fr
Description:
------------
Calling getRealPath on an DirectoryIterator make PHP crash, 
getPath works fine.


The problem also happens with php 5.2.3

Reproduce code:
---------------
<?php
$it = new DirectoryIterator("/tmp");

foreach ($it as $e)
{
  $path = $e->getRealPath();
}
?>

Actual result:
--------------
(gdb) run test.php
Starting program: /home/wwwdev/php/bin/php test.php
Failed to read a valid object file image from memory.

Program received signal SIGSEGV, Segmentation fault.
tsrm_realpath (path=0x0, real_path=0xbfb0f20c "6?\025\b\001")
    at /home/wwwdev/php5.2-200708201630/TSRM/tsrm_virtual_cwd.c:1266
1266            if (!*path) {
(gdb) bt
#0  tsrm_realpath (path=0x0, real_path=0xbfb0f20c "6?\025\b\001")
    at /home/wwwdev/php5.2-200708201630/TSRM/tsrm_virtual_cwd.c:1266
#1  0x080a1c8c in zim_spl_SplFileInfo_getRealPath (ht=0, return_value=0xb7d0519c,
    return_value_ptr=0x0, this_ptr=0xb7d04598, return_value_used=1)
    at /home/wwwdev/php5.2-200708201630/ext/spl/spl_directory.c:861
#2  0x08175cc2 in zend_do_fcall_common_helper_SPEC (execute_data=0xbfb103e0)
    at /home/wwwdev/php5.2-200708201630/Zend/zend_vm_execute.h:202
#3  0x08174b58 in execute (op_array=0xb7d04a40)
    at /home/wwwdev/php5.2-200708201630/Zend/zend_vm_execute.h:94
#4  0x081575f4 in zend_execute_scripts (type=8, retval=<value optimized out>,
    file_count=3) at /home/wwwdev/php5.2-200708201630/Zend/zend.c:1134
#5  0x08117c00 in php_execute_script (primary_file=0xbfb1279c)
    at /home/wwwdev/php5.2-200708201630/main/main.c:1982
#6  0x081d1674 in main (argc=2, argv=0xbfb128a4)
    at /home/wwwdev/php5.2-200708201630/sapi/cli/php_cli.c:1140


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-21 19:02 UTC] kfou at free dot fr
Same problem using last win32 build:

$ php --version
PHP 5.2.4RC3-dev (cli) (built: Aug 21 2007 12:04:26) 
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies

$ gdb --quiet php(gdb) run test.php
Starting program: c:\php/php.exe test.php

Program received signal SIGSEGV, Segmentation fault.
0x100ddc90 in ?? ()
 [2007-08-21 22:47 UTC] johannes@php.net
This bug has been fixed in CVS.

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/.
 
Thank you for the report, and for helping us make PHP better.


 [2010-12-09 13:39 UTC] eyalt@php.net
Automatic comment from SVN on behalf of eyalt
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=306121
Log: test bug42364 included a superfluous ?&gt;
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC