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 @@ -1148,8 +1148,8 @@ static void init_request_info(void)
1148
1148
path_info = script_path_translated + ptlen ;
1149
1149
tflag = (slen != 0 && (!orig_path_info || strcmp (orig_path_info , path_info ) != 0 ));
1150
1150
} else {
1151
- path_info = env_path_info ? env_path_info + pilen - slen : NULL ;
1152
- tflag = (orig_path_info != path_info );
1151
+ path_info = ( env_path_info && pilen > slen ) ? env_path_info + pilen - slen : NULL ;
1152
+ tflag = path_info && (orig_path_info != path_info );
1153
1153
}
1154
1154
1155
1155
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 @@ -513,7 +513,7 @@ class Tester
513
513
return new Response (null , true );
514
514
}
515
515
if (is_null ($ uri )) {
516
- $ uri = $ this ->makeFile ( ' src.php ' , $ this -> code );
516
+ $ uri = $ this ->makeSourceFile ( );
517
517
}
518
518
519
519
$ params = array_merge (
@@ -538,7 +538,6 @@ class Tester
538
538
],
539
539
$ headers
540
540
);
541
-
542
541
try {
543
542
$ this ->response = new Response (
544
543
$ this ->getClient ($ address , $ connKeepAlive )->request_data ($ params , false )
@@ -944,6 +943,14 @@ class Tester
944
943
return $ filePath ;
945
944
}
946
945
946
+ /**
947
+ * @return string
948
+ */
949
+ public function makeSourceFile ()
950
+ {
951
+ return $ this ->makeFile ('src.php ' , $ this ->code );
952
+ }
953
+
947
954
/**
948
955
* @param string|null $msg
949
956
*/
You can’t perform that action at this time.
0 commit comments