From c1e510aea8f4cebb6863a65b9219201951912819 Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Fri, 11 Nov 2011 21:39:11 +0000 Subject: [PATCH] - Fixed bug #60261 (phar dos null pointer) --- ext/phar/tests/bug60261.phpt | 19 +++++++++++++++++++ ext/spl/spl_directory.c | 5 ++++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 ext/phar/tests/bug60261.phpt diff --git a/ext/phar/tests/bug60261.phpt b/ext/phar/tests/bug60261.phpt new file mode 100644 index 0000000000..1b6cd7a7cd --- /dev/null +++ b/ext/phar/tests/bug60261.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #60261 (phar dos null pointer) +--SKIPIF-- + +--FILE-- +getLinkTarget(); +} catch (Exception $e) { + echo $e->getMessage(), "\n"; +} + +?> +--EXPECTF-- + +Warning: Phar::__construct() expects at least 1 parameter, 0 given in %s on line %d +SplFileInfo::getLinkTarget(): Empty filename diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 2223c3a000..cc2a9d8c64 100755 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -1230,7 +1230,10 @@ SPL_METHOD(SplFileInfo, getLinkTarget) zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling TSRMLS_CC); #if defined(PHP_WIN32) || HAVE_SYMLINK - if (!IS_ABSOLUTE_PATH(intern->file_name, intern->file_name_len)) { + if (intern->file_name == NULL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty filename"); + RETURN_FALSE; + } else if (!IS_ABSOLUTE_PATH(intern->file_name, intern->file_name_len)) { char expanded_path[MAXPATHLEN]; if (!expand_filepath_with_mode(intern->file_name, expanded_path, NULL, 0, CWD_EXPAND TSRMLS_CC)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "No such file or directory"); -- 2.40.0