diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2019-01-09 14:26:18 +0100 |
---|---|---|
committer | Stanislav Malyshev <stas@php.net> | 2019-03-03 18:23:46 -0800 |
commit | 254a5914ad7f9dbdc4f6090229f6b0f4317a695e (patch) | |
tree | cb39a1c9c782c947946ac9d5dbcd794061f472a9 | |
parent | 7f0ab7c20c83a52862ad7c8acf31c3fa739f1274 (diff) | |
download | php-git-254a5914ad7f9dbdc4f6090229f6b0f4317a695e.tar.gz |
Fix #77431 SplFileInfo::__construct() accepts NUL bytes
`SplFileInfo::__construct()` has to expect a path instead of a string,
analogous to `SplFileObject::__construct()`.
-rw-r--r-- | ext/spl/spl_directory.c | 2 | ||||
-rw-r--r-- | ext/spl/tests/bug77431.phpt | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index fc4001ae1f..748b1549b5 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -1110,7 +1110,7 @@ SPL_METHOD(SplFileInfo, __construct) char *path; size_t len; - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &path, &len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &path, &len) == FAILURE) { return; } diff --git a/ext/spl/tests/bug77431.phpt b/ext/spl/tests/bug77431.phpt new file mode 100644 index 0000000000..eb1ca96b75 --- /dev/null +++ b/ext/spl/tests/bug77431.phpt @@ -0,0 +1,9 @@ +--TEST-- +Bug #77431 (SplFileInfo::__construct() accepts NUL bytes) +--FILE-- +<?php +new SplFileInfo("bad\0good"); +?> +--EXPECTF-- +Fatal error: Uncaught TypeError: SplFileInfo::__construct() expects parameter 1 to be a valid path, string given in %s:%d +Stack trace:%A
\ No newline at end of file |