1--TEST--
2FPM: bug78599 - env_path_info underflow - CVE-2019-11043
3--SKIPIF--
4<?php include "skipif.inc"; ?>
5--FILE--
6<?php
7
8require_once "tester.inc";
9
10$cfg = <<<EOT
11[global]
12error_log = {{FILE:LOG}}
13[unconfined]
14listen = {{ADDR}}
15pm = dynamic
16pm.max_children = 5
17pm.start_servers = 1
18pm.min_spare_servers = 1
19pm.max_spare_servers = 3
20EOT;
21
22$code = <<<EOT
23<?php
24echo "Test Start\n";
25var_dump(\$_SERVER["PATH_INFO"]);
26echo "Test End\n";
27EOT;
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?>
54Done
55--EXPECT--
56Done
57--CLEAN--
58<?php
59require_once "tester.inc";
60FPM\Tester::clean();
61?>
62