johannes Tue Aug 21 22:43:38 2007 UTC
Added files:
/php-src/ext/spl/tests bug42364.phpt
Modified files:
/php-src/ext/spl spl_directory.c
Log:
- Fixed Bug #42364 Crash when using getRealPath with DirectoryIterator
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.134&r2=1.135&diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.134
php-src/ext/spl/spl_directory.c:1.135
--- php-src/ext/spl/spl_directory.c:1.134 Tue Jun 5 13:51:29 2007
+++ php-src/ext/spl/spl_directory.c Tue Aug 21 22:43:38 2007
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_directory.c,v 1.134 2007/06/05 13:51:29 tony2001 Exp $ */
+/* $Id: spl_directory.c,v 1.135 2007/08/21 22:43:38 johannes Exp $ */
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -1020,13 +1020,17 @@
php_set_error_handling(EH_THROW, spl_ce_RuntimeException TSRMLS_CC);
+ if (intern->type == SPL_FS_DIR && !intern->file_name.v &&
intern->u.dir.entry.d_name[0]) {
+ spl_filesystem_object_get_file_name(intern TSRMLS_CC);
+ }
+
if (intern->file_name_type == IS_UNICODE) {
php_stream_path_encode(NULL, &filename, &filename_len,
intern->file_name.u, intern->file_name_len, REPORT_ERRORS, FG(default_context));
} else {
filename = intern->file_name.s;
}
- if (VCWD_REALPATH(filename, buff)) {
+ if (filename && VCWD_REALPATH(filename, buff)) {
#ifdef ZTS
if (VCWD_ACCESS(buff, F_OK)) {
RETVAL_FALSE;
@@ -1044,6 +1048,11 @@
} else {
RETVAL_FALSE;
}
+
+ if (intern->file_name_type == IS_UNICODE && filename) {
+ efree(filename);
+ }
+
php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
}
/* }}} */
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