File tree Expand file tree Collapse file tree 3 files changed +72
-4
lines changed Expand file tree Collapse file tree 3 files changed +72
-4
lines changed Original file line number Diff line number Diff line change @@ -1138,8 +1138,8 @@ static void init_request_info(void)
1138
1138
path_info = script_path_translated + ptlen ;
1139
1139
tflag = (slen != 0 && (!orig_path_info || strcmp (orig_path_info , path_info ) != 0 ));
1140
1140
} else {
1141
- path_info = env_path_info ? env_path_info + pilen - slen : NULL ;
1142
- tflag = (orig_path_info != path_info );
1141
+ path_info = ( env_path_info && pilen > slen ) ? env_path_info + pilen - slen : NULL ;
1142
+ tflag = path_info && (orig_path_info != path_info );
1143
1143
}
1144
1144
1145
1145
if (tflag ) {
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ FPM: bug78599 - env_path_info underflow - CVE-2019-11043
3
+ --SKIPIF--
4
+ <?php include "skipif.inc " ; ?>
5
+ --FILE--
6
+ <?php
7
+
8
+ require_once "tester.inc " ;
9
+
10
+ $ cfg = <<<EOT
11
+ [global]
12
+ error_log = {{FILE:LOG}}
13
+ [unconfined]
14
+ listen = {{ADDR}}
15
+ pm = dynamic
16
+ pm.max_children = 5
17
+ pm.start_servers = 1
18
+ pm.min_spare_servers = 1
19
+ pm.max_spare_servers = 3
20
+ EOT ;
21
+
22
+ $ code = <<<EOT
23
+ <?php
24
+ echo "Test Start \n";
25
+ var_dump( \$_SERVER["PATH_INFO"]);
26
+ echo "Test End \n";
27
+ EOT ;
28
+
29
+ $ tester = new FPM \Tester ($ cfg , $ code );
30
+ $ tester ->start ();
31
+ $ tester ->expectLogStartNotices ();
32
+ $ uri = $ tester ->makeSourceFile ();
33
+ $ tester
34
+ ->request (
35
+ '' ,
36
+ [
37
+ 'SCRIPT_FILENAME ' => $ uri . "/ " . str_repeat ('A ' , 35 ),
38
+ 'PATH_INFO ' => '' ,
39
+ 'HTTP_HUI ' => str_repeat ('PTEST ' , 1000 ),
40
+ ],
41
+ $ uri
42
+ )
43
+ ->expectBody (
44
+ [
45
+ 'Test Start ' ,
46
+ 'string(0) "" ' ,
47
+ 'Test End '
48
+ ]
49
+ );
50
+ $ tester ->terminate ();
51
+ $ tester ->close ();
52
+
53
+ ?>
54
+ Done
55
+ --EXPECT--
56
+ Done
57
+ --CLEAN--
58
+ <?php
59
+ require_once "tester.inc " ;
60
+ FPM \Tester::clean ();
61
+ ?>
Original file line number Diff line number Diff line change @@ -509,7 +509,7 @@ class Tester
509
509
return new Response (null , true );
510
510
}
511
511
if (is_null ($ uri )) {
512
- $ uri = $ this ->makeFile ( ' src.php ' , $ this -> code );
512
+ $ uri = $ this ->makeSourceFile ( );
513
513
}
514
514
515
515
$ params = array_merge (
@@ -534,7 +534,6 @@ class Tester
534
534
],
535
535
$ headers
536
536
);
537
-
538
537
try {
539
538
$ this ->response = new Response (
540
539
$ this ->getClient ($ address , $ connKeepAlive )->request_data ($ params , false )
@@ -940,6 +939,14 @@ class Tester
940
939
return $ filePath ;
941
940
}
942
941
942
+ /**
943
+ * @return string
944
+ */
945
+ public function makeSourceFile ()
946
+ {
947
+ return $ this ->makeFile ('src.php ' , $ this ->code );
948
+ }
949
+
943
950
/**
944
951
* @param string|null $msg
945
952
*/
You can’t perform that action at this time.
0 commit comments