1--TEST--
2Bug #66731: file: infinite recursion
3--EXTENSIONS--
4fileinfo
5--FILE--
6<?php
7$fd = __DIR__.'/cve-2014-1943.data';
8$fm = __DIR__.'/cve-2014-1943.magic';
9
10$a = "\105\122\000\000\000\000\000";
11$b = str_repeat("\001", 250000);
12$m =  "0           byte        x\n".
13      ">(1.b)      indirect    x\n";
14
15file_put_contents($fd, $a);
16$fi = finfo_open(FILEINFO_NONE);
17var_dump(finfo_file($fi, $fd));
18finfo_close($fi);
19
20file_put_contents($fd, $b);
21file_put_contents($fm, $m);
22$fi = finfo_open(FILEINFO_NONE, $fm);
23var_dump(finfo_file($fi, $fd));
24finfo_close($fi);
25?>
26Done
27--CLEAN--
28<?php
29@unlink(__DIR__.'/cve-2014-1943.data');
30@unlink(__DIR__.'/cve-2014-1943.magic');
31?>
32--EXPECTF--
33string(%d) "%s"
34
35Warning: finfo_file(): Failed identify data 0:indirect count (%d) exceeded in %s on line %d
36bool(false)
37Done
38