Skip to content

Commit 254a591

Browse files
cmb69smalyshev
authored andcommitted
Fix #77431 SplFileInfo::__construct() accepts NUL bytes
`SplFileInfo::__construct()` has to expect a path instead of a string, analogous to `SplFileObject::__construct()`.
1 parent 7f0ab7c commit 254a591

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

ext/spl/spl_directory.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ SPL_METHOD(SplFileInfo, __construct)
11101110
char *path;
11111111
size_t len;
11121112

1113-
if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &path, &len) == FAILURE) {
1113+
if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &path, &len) == FAILURE) {
11141114
return;
11151115
}
11161116

ext/spl/tests/bug77431.phpt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
--TEST--
2+
Bug #77431 (SplFileInfo::__construct() accepts NUL bytes)
3+
--FILE--
4+
<?php
5+
new SplFileInfo("bad\0good");
6+
?>
7+
--EXPECTF--
8+
Fatal error: Uncaught TypeError: SplFileInfo::__construct() expects parameter 1 to be a valid path, string given in %s:%d
9+
Stack trace:%A

0 commit comments

Comments
 (0)