1--TEST--
2Bug #66731: file: extensive backtracking
3--EXTENSIONS--
4fileinfo
5--SKIPIF--
6<?php
7if (defined("PHP_DEBUG") && PHP_DEBUG)
8    die("skip not suitable for debug build");
9if (getenv('SKIP_PERF_SENSITIVE'))
10    die("skip performance sensitive test");
11?>
12--FILE--
13<?php
14$fd = __DIR__.'/cve-2014-3538.data';
15
16file_put_contents($fd,
17  'try:' .
18  str_repeat("\n", 1000000));
19
20$fi = finfo_open(FILEINFO_NONE);
21$t = microtime(true);
22var_dump(finfo_file($fi, $fd));
23$t = microtime(true) - $t;
24finfo_close($fi);
25if ($t < 1.5) {
26    echo "Ok\n";
27} else {
28    printf("Failed, time=%.2f\n", $t);
29}
30
31?>
32Done
33--CLEAN--
34<?php
35@unlink(__DIR__.'/cve-2014-3538.data');
36?>
37--EXPECTF--
38string(%d) "%s"
39Ok
40Done
41