Annotation of embedaddon/php/ext/fileinfo/tests/bug61964.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Bug #61964 (finfo_open with directory cause invalid free)
                      3: --SKIPIF--
                      4: <?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
                      5: --FILE--
                      6: <?php
                      7: 
                      8: $magic_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'magic';
                      9: 
                     10: $ret = @finfo_open(FILEINFO_NONE, $magic_file . ".non-exits");
                     11: var_dump($ret);
                     12: 
                     13: $dir = __DIR__ . "/test-folder";
                     14: @mkdir($dir);
                     15: 
                     16: $magic_file_copy = $dir . "/magic.copy";
                     17: $magic_file_copy2 = $magic_file_copy . "2";
                     18: copy($magic_file, $magic_file_copy);
                     19: copy($magic_file, $magic_file_copy2);
                     20: 
                     21: $ret = finfo_open(FILEINFO_NONE, $dir);
                     22: var_dump($ret);
                     23: 
                     24: $ret = @finfo_open(FILEINFO_NONE, $dir);
                     25: var_dump($ret);
                     26: 
                     27: $ret = @finfo_open(FILEINFO_NONE, $dir. "/non-exits-dir");
                     28: var_dump($ret);
                     29: 
                     30: // write some test files to test folder
                     31: file_put_contents($dir . "/test1.txt", "string\n> Core\n> Me");
                     32: file_put_contents($dir . "/test2.txt", "a\nb\n");
                     33: @mkdir($dir . "/test-inner-folder");
                     34: 
                     35: finfo_open(FILEINFO_NONE, $dir);
                     36: echo "DONE: testing dir with files\n";
                     37: 
                     38: rmdir($dir . "/test-inner-folder");
                     39: unlink($dir . "/test1.txt");
                     40: unlink($dir . "/test2.txt");
                     41: 
                     42: unlink($magic_file_copy);
                     43: unlink($magic_file_copy2);
                     44: rmdir($dir);
                     45: ?>
                     46: ===DONE===
                     47: --EXPECTF--
                     48: bool(false)
                     49: resource(%d) of type (file_info)
                     50: resource(%d) of type (file_info)
                     51: bool(false)
                     52: 
                     53: Notice: finfo_open(): Warning: offset `string' invalid in %sbug61964.php on line %d
                     54: 
                     55: Notice: finfo_open(): Warning: offset ` Core' invalid in %sbug61964.php on line %d
                     56: 
                     57: Notice: finfo_open(): Warning: type `Core' invalid in %sbug61964.php on line %d
                     58: 
                     59: Notice: finfo_open(): Warning: offset `a' invalid in %sbug61964.php on line %d
                     60: 
                     61: Notice: finfo_open(): Warning: type `a' invalid in %sbug61964.php on line %d
                     62: 
                     63: Notice: finfo_open(): Warning: offset `b' invalid in %sbug61964.php on line %d
                     64: 
                     65: Notice: finfo_open(): Warning: type `b' invalid in %sbug61964.php on line %d
                     66: 
                     67: Warning: finfo_open(): Failed to load magic database at '%stest-folder'. in %sbug61964.php on line %d
                     68: DONE: testing dir with files
                     69: ===DONE===

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>