From: Johannes Schlüter Date: Tue, 21 Aug 2007 22:45:53 +0000 (+0000) Subject: - MFH: Fix Bug #42364 Crash when using getRealPath with DirectoryIterator X-Git-Tag: php-5.2.4RC3~14 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=254992907cf6b57989736d8dff33ada93fc2fdbd;p=php - MFH: Fix Bug #42364 Crash when using getRealPath with DirectoryIterator --- diff --git a/NEWS b/NEWS index 7395da7159..32c11d31e9 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,8 @@ PHP NEWS 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) diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index b9fc22dfdd..6529bbc1d9 100755 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -858,7 +858,11 @@ SPL_METHOD(SplFileInfo, getRealPath) 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; diff --git a/ext/spl/tests/bug42364.phpt b/ext/spl/tests/bug42364.phpt new file mode 100644 index 0000000000..b218be36af --- /dev/null +++ b/ext/spl/tests/bug42364.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #42364 (Crash when using getRealPath with DirectoryIterator) +--SKIPIF-- + +--FILE-- +getRealPath()) != "string") { + echo $e->getFilename(), " is a ", gettype($e->getRealPath()), "\n"; + } +} + +echo "===DONE===" +?> +--EXPECT-- +===DONE===