|
| 1 | +--TEST-- |
| 2 | +GHSA-9pqp-7h25-4f32 |
| 3 | +--SKIPIF-- |
| 4 | +<?php |
| 5 | +if (!getenv('TEST_PHP_CGI_EXECUTABLE')) { |
| 6 | + die("skip php-cgi not available"); |
| 7 | +} |
| 8 | +?> |
| 9 | +--FILE-- |
| 10 | +<?php |
| 11 | + |
| 12 | +const FILLUNIT = 5 * 1024; |
| 13 | + |
| 14 | +function test($boundaryLen) { |
| 15 | + printf("Boundary len: %d\n", $boundaryLen); |
| 16 | + |
| 17 | + $cmd = [ |
| 18 | + getenv('TEST_PHP_CGI_EXECUTABLE'), |
| 19 | + '-C', |
| 20 | + '-n', |
| 21 | + __DIR__ . '/GHSA-9pqp-7h25-4f32.inc', |
| 22 | + ]; |
| 23 | + |
| 24 | + $boundary = str_repeat('A', $boundaryLen); |
| 25 | + $body = "" |
| 26 | + . "--$boundary\r\n" |
| 27 | + . "Content-Disposition: form-data; name=\"koko\"\r\n" |
| 28 | + . "\r\n" |
| 29 | + . "BBB\r\n--" . substr($boundary, 0, -1) . "CCC\r\n" |
| 30 | + . "--$boundary--\r\n" |
| 31 | + ; |
| 32 | + |
| 33 | + $env = array_merge($_ENV, [ |
| 34 | + 'REDIRECT_STATUS' => '1', |
| 35 | + 'CONTENT_TYPE' => "multipart/form-data; boundary=$boundary", |
| 36 | + 'CONTENT_LENGTH' => strlen($body), |
| 37 | + 'REQUEST_METHOD' => 'POST', |
| 38 | + 'SCRIPT_FILENAME' => __DIR__ . '/GHSA-9pqp-7h25-4f32.inc', |
| 39 | + ]); |
| 40 | + |
| 41 | + $spec = [ |
| 42 | + 0 => ['pipe', 'r'], |
| 43 | + 1 => STDOUT, |
| 44 | + 2 => STDOUT, |
| 45 | + ]; |
| 46 | + |
| 47 | + $pipes = []; |
| 48 | + |
| 49 | + print "Starting...\n"; |
| 50 | + |
| 51 | + $handle = proc_open($cmd, $spec, $pipes, getcwd(), $env); |
| 52 | + |
| 53 | + fwrite($pipes[0], $body); |
| 54 | + |
| 55 | + $status = proc_close($handle); |
| 56 | + |
| 57 | + print "\n"; |
| 58 | +} |
| 59 | + |
| 60 | +for ($offset = -1; $offset <= 1; $offset++) { |
| 61 | + test(FILLUNIT - strlen("\r\n--") + $offset); |
| 62 | +} |
| 63 | + |
| 64 | +?> |
| 65 | +--EXPECTF-- |
| 66 | +Boundary len: 5115 |
| 67 | +Starting... |
| 68 | +X-Powered-By: %s |
| 69 | +Content-type: text/html; charset=UTF-8 |
| 70 | + |
| 71 | +Hello world |
| 72 | +array(1) { |
| 73 | + ["koko"]=> |
| 74 | + string(5124) "BBB |
| 75 | +--AAA%sCCC" |
| 76 | +} |
| 77 | + |
| 78 | +Boundary len: 5116 |
| 79 | +Starting... |
| 80 | +X-Powered-By: %s |
| 81 | +Content-type: text/html; charset=UTF-8 |
| 82 | + |
| 83 | +Hello world |
| 84 | +array(1) { |
| 85 | + ["koko"]=> |
| 86 | + string(5125) "BBB |
| 87 | +--AAA%sCCC" |
| 88 | +} |
| 89 | + |
| 90 | +Boundary len: 5117 |
| 91 | +Starting... |
| 92 | +X-Powered-By: %s |
| 93 | +Content-type: text/html; charset=UTF-8 |
| 94 | + |
| 95 | +<br /> |
| 96 | +<b>Warning</b>: Boundary too large in multipart/form-data POST data in <b>Unknown</b> on line <b>0</b><br /> |
| 97 | +Hello world |
| 98 | +array(0) { |
| 99 | +} |
| 100 | + |
0 commit comments