From 32a728d351aab4bac28790697cd6820a8843645f Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sun, 19 Aug 2018 14:03:47 +0200 Subject: Fix #68825: Exception in DirectoryIterator::getLinkTarget() intern->file_name may not have been properly set when DirectoryIterator::getLinkTarget() is called, so we make sure it is before using it. --- NEWS | 1 + ext/spl/spl_directory.c | 3 +++ ext/spl/tests/bug68825.phpt | 25 +++++++++++++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 ext/spl/tests/bug68825.phpt diff --git a/NEWS b/NEWS index 78d9dba0b3..727508aac5 100644 --- a/NEWS +++ b/NEWS @@ -38,6 +38,7 @@ PHP NEWS (Kevin Abel) - SPL: + . Fixed bug #68825 (Exception in DirectoryIterator::getLinkTarget()). (cmb) . Fixed bug #68175 (RegexIterator pregFlags are NULL instead of 0). (Tim Siebels) diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 4942799cf7..fc4001ae1f 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -1229,6 +1229,9 @@ SPL_METHOD(SplFileInfo, getLinkTarget) zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling); + if (intern->file_name == NULL) { + spl_filesystem_object_get_file_name(intern); + } #if defined(PHP_WIN32) || HAVE_SYMLINK if (intern->file_name == NULL) { php_error_docref(NULL, E_WARNING, "Empty filename"); diff --git a/ext/spl/tests/bug68825.phpt b/ext/spl/tests/bug68825.phpt new file mode 100644 index 0000000000..b1ed5fb60f --- /dev/null +++ b/ext/spl/tests/bug68825.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #68825 (Exception in DirectoryIterator::getLinkTarget()) +--FILE-- +getFilename()) { + var_dump($entry->getLinkTarget()); + } +} +?> +===DONE=== +--EXPECTF-- +string(%d) "%s%eext%espl%etests%ebug68825.php" +===DONE=== +--CLEAN-- + -- cgit v1.2.1