johannes                Tue Aug 21 22:45:53 2007 UTC

  Added files:                 (Branch: PHP_5_2)
    /php-src/ext/spl/tests      bug42364.phpt 

  Modified files:              
    /php-src    NEWS 
    /php-src/ext/spl    spl_directory.c 
  Log:
  - MFH: Fix Bug #42364 Crash when using getRealPath with DirectoryIterator
  
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.901&r2=1.2027.2.547.2.902&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.901 php-src/NEWS:1.2027.2.547.2.902
--- php-src/NEWS:1.2027.2.547.2.901     Sun Aug 19 16:11:17 2007
+++ php-src/NEWS        Tue Aug 21 22:45:52 2007
@@ -7,6 +7,8 @@
 16 Aug 2007, PHP 5.2.4RC2
 - Fixed oci8 and PDO_OCI extensions to allow configuring with Oracle 11g client
   libraries. (Chris Jones)
+- Fixed Bug #42364 (Crash when using getRealPath with DirectoryIterator).
+  (Johannes)
 - Fixed bug #42292 ($PHP_CONFIG not set for phpized builds). (Jani)
 - Fixed bug #42261 (header wrong for date field). (roberto at spadim dot com
   dot br, Ilia)
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.45.2.27.2.21&r2=1.45.2.27.2.22&diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.45.2.27.2.21 
php-src/ext/spl/spl_directory.c:1.45.2.27.2.22
--- php-src/ext/spl/spl_directory.c:1.45.2.27.2.21      Tue Jun  5 12:02:46 2007
+++ php-src/ext/spl/spl_directory.c     Tue Aug 21 22:45:53 2007
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_directory.c,v 1.45.2.27.2.21 2007/06/05 12:02:46 tony2001 Exp $ */
+/* $Id: spl_directory.c,v 1.45.2.27.2.22 2007/08/21 22:45:53 johannes Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -858,7 +858,11 @@
 
        php_set_error_handling(EH_THROW, spl_ce_RuntimeException TSRMLS_CC);
 
-       if (VCWD_REALPATH(intern->file_name, buff)) {
+       if (intern->type == SPL_FS_DIR && !intern->file_name && 
intern->u.dir.entry.d_name[0]) {
+               spl_filesystem_object_get_file_name(intern TSRMLS_CC);
+       }
+
+       if (intern->file_name_len && VCWD_REALPATH(intern->file_name, buff)) {
 #ifdef ZTS
                if (VCWD_ACCESS(buff, F_OK)) {
                        RETVAL_FALSE;

http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/bug42364.phpt?view=markup&rev=1.1
Index: php-src/ext/spl/tests/bug42364.phpt
+++ php-src/ext/spl/tests/bug42364.phpt
--TEST--
Bug #42364 (Crash when using getRealPath with DirectoryIterator)
--SKIPIF--
<?php if (!extension_loaded("spl")) print "skip"; ?>
--FILE--
<?php
$it = new DirectoryIterator(dirname(__FILE__));

$count = 0;

foreach ($it as $e) {
    $count++;
    $type = gettype($e->getRealPath());
    if ($type != "string" && $type != "unicode") {
        echo $e->getFilename(), " is a ", gettype($e->getRealPath()), "\n";
    }
}

if ($count > 0) {
    echo "Found $count entries!\n";
}
echo "===DONE==="
?>
--EXPECTF--
Found %i entries!
===DONE===

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to