bug61964-mb.phpt 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. --TEST--
  2. Bug #61964 (finfo_open with directory cause invalid free)
  3. --EXTENSIONS--
  4. fileinfo
  5. --FILE--
  6. <?php
  7. $magic_file = __DIR__ . DIRECTORY_SEPARATOR . 'magic私はガラスを食べられます';
  8. $ret = @finfo_open(FILEINFO_NONE, $magic_file . ".non-exits私はガラスを食べられます");
  9. var_dump($ret);
  10. $dir = __DIR__ . "/bug61964-mb";
  11. @mkdir($dir);
  12. $magic_file_copy = $dir . "/magic私はガラスを食べられます.copy";
  13. $magic_file_copy2 = $magic_file_copy . "2";
  14. copy($magic_file, $magic_file_copy);
  15. copy($magic_file, $magic_file_copy2);
  16. $ret = finfo_open(FILEINFO_NONE, $dir);
  17. var_dump($ret);
  18. $ret = @finfo_open(FILEINFO_NONE, $dir);
  19. var_dump($ret);
  20. $ret = @finfo_open(FILEINFO_NONE, $dir. "/non-exits-dir私はガラスを食べられます");
  21. var_dump($ret);
  22. // write some test files to test folder
  23. file_put_contents($dir . "/test1.txt", "string\n> Core\n> Me");
  24. file_put_contents($dir . "/test2.txt", "a\nb\n");
  25. @mkdir($dir . "/test-inner-folder私はガラスを食べられます");
  26. finfo_open(FILEINFO_NONE, $dir);
  27. echo "DONE: testing dir with files\n";
  28. rmdir($dir . "/test-inner-folder私はガラスを食べられます");
  29. unlink($dir . "/test1.txt");
  30. unlink($dir . "/test2.txt");
  31. unlink($magic_file_copy);
  32. unlink($magic_file_copy2);
  33. rmdir($dir);
  34. ?>
  35. --EXPECTF--
  36. bool(false)%A
  37. object(finfo)#%d (0) {
  38. }
  39. object(finfo)#%d (0) {
  40. }
  41. bool(false)%A
  42. Warning: finfo_open(): offset `string' invalid in %sbug61964-mb.php on line %d
  43. Warning: finfo_open(): offset ` Core' invalid in %sbug61964-mb.php on line %d
  44. Warning: finfo_open(): offset ` Me' invalid in %sbug61964-mb.php on line %d
  45. Warning: finfo_open(): offset `a' invalid in %sbug61964-mb.php on line %d
  46. Warning: finfo_open(): offset `b' invalid in %sbug61964-mb.php on line %d
  47. Warning: finfo_open(): Failed to load magic database at "%sbug61964-mb" in %sbug61964-mb.php on line %d
  48. DONE: testing dir with files