aboutsummaryrefslogtreecommitdiff
blob: 1d806ca39c530ec63a5f02260a23f4c6e9597149 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
From ae1fad5bb773c4c58c2249472b5c06ca05ebe702 Mon Sep 17 00:00:00 2001
From: "Christoph M. Becker" <cmbecker69@gmx.de>
Date: Wed, 9 Jan 2019 14:26:18 +0100
Subject: [PATCH] Fix #77431 SplFileInfo::__construct() accepts NUL bytes

`SplFileInfo::__construct()` has to expect a path instead of a string,
analogous to `SplFileObject::__construct()`.
---
 ext/spl/spl_directory.c     | 2 +-
 ext/spl/tests/bug77431.phpt | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)
 create mode 100644 ext/spl/tests/bug77431.phpt

diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c
index ef2e72d..e690b94 100644
--- a/ext/spl/spl_directory.c
+++ b/ext/spl/spl_directory.c
@@ -1131,7 +1131,7 @@ SPL_METHOD(SplFileInfo, __construct)
 
 	zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling TSRMLS_CC);
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &path, &len) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &path, &len) == FAILURE) {
 		zend_restore_error_handling(&error_handling TSRMLS_CC);
 		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 exception 'RuntimeException' with message 'SplFileInfo::__construct() expects parameter 1 to be a valid path, string given' in %s:%d
+Stack trace:%A
\ No newline at end of file
-- 
2.1.4