com php-src: Fix #77431 SplFileInfo::__construct() accepts NUL bytes: ext/spl/spl_directory.c ext /spl/tests/bug77431.phpt
| From: | Stanislav Malyshev | Date: | Mon, 04 Mar 2019 02:23:46 +0000 |
| Subject: | com php-src: Fix #77431 SplFileInfo::__construct() accepts NUL bytes: ext/spl/spl_directory.c ext /spl/tests/bug77431.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-104959@lists.php.net to get a copy of this message | ||
Commit: 254a5914ad7f9dbdc4f6090229f6b0f4317a695e
Author: Christoph M. Becker <cmbecker69@gmx.de> Wed, 9 Jan 2019 14:26:18 +0100
Committer: Stanislav Malyshev <stas@php.net> Sun, 3 Mar 2019 18:23:46 -0800
Parents: 7f0ab7c20c83a52862ad7c8acf31c3fa739f1274
Branches: PHP-7.1 PHP-7.2 PHP-7.3 PHP-7.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=254a5914ad7f9dbdc4f6090229f6b0f4317a695e
Log:
Fix #77431 SplFileInfo::__construct() accepts NUL bytes
SplFileInfo::__construct() has to expect a path instead of a string,
analogous to SplFileObject::__construct().
Bugs:
https://bugs.php.net/77431
Changed paths:
M ext/spl/spl_directory.c
A ext/spl/tests/bug77431.phpt
Diff:
diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c
index fc4001a..748b154 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 0000000..eb1ca96
--- /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