1--TEST--
2FPM: GH-15335 - PHP_AUTH shutdown  use after free
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}}
13log_level = notice
14[unconfined]
15listen = {{ADDR}}
16pm = static
17pm.max_children = 1
18catch_workers_output = yes
19php_admin_value[cgi.fix_pathinfo] = no
20EOT;
21
22$code = <<<EOT
23<?php
24echo \$_SERVER["SCRIPT_NAME"] . "\n";
25echo \$_SERVER["SCRIPT_FILENAME"] . "\n";
26echo \$_SERVER["PHP_SELF"];
27EOT;
28
29$tester = new FPM\Tester($cfg, $code);
30[$sourceFilePath, $scriptName] = $tester->createSourceFileAndScriptName();
31$tester->start();
32$tester->expectLogStartNotices();
33$tester
34    ->request(
35        headers: [ "HTTP_AUTHORIZATION" => "Basic Zm9vOg==", "REQUEST_METHOD" => "GET"],
36        uri: $scriptName,
37        address: '{{ADDR}}',
38        scriptFilename: __DIR__ . "/__unknown.php",
39        scriptName: "/",
40    )
41    ->expectStatus('404 Not Found');
42$tester
43    ->request(
44        uri: $scriptName,
45        address: '{{ADDR}}',
46        params: [],
47    );
48$tester->expectNoLogPattern("/zend_mm_heap corrupted/");
49$tester->terminate();
50$tester->expectLogTerminatingNotices();
51$tester->close();
52
53?>
54Done
55--EXPECT--
56Done
57--CLEAN--
58<?php
59require_once "tester.inc";
60FPM\Tester::clean();
61?>
62