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