realpath_bug77484.phpt 682 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. --TEST--
  2. Bug #77484 Zend engine crashes when calling realpath in invalid working dir
  3. --SKIPIF--
  4. <?php
  5. if (substr(PHP_OS, 0, 3) == 'WIN') {
  6. die("skip can't remove CWD on Windows");
  7. }
  8. if (PHP_ZTS) {
  9. /* TODO eliminate difference in TS build. */
  10. die("skip Not for ZTS");
  11. }
  12. ?>
  13. --FILE--
  14. <?php
  15. $old_cwd = getcwd();
  16. mkdir(__DIR__ . "/foo");
  17. chdir(__DIR__ . "/foo");
  18. rmdir(__DIR__ . "/foo");
  19. // Outputs: / (incorrect)
  20. $new_cwd = getcwd();
  21. // Outputs: false (correct)
  22. $rp0 = realpath('');
  23. // Crash
  24. $rp1 = realpath('.');
  25. $rp2 = realpath('./');
  26. var_dump($old_cwd, $new_cwd, $rp0, $rp1, $rp2);
  27. ?>
  28. --EXPECTF--
  29. string(%d) "%s"
  30. bool(false)
  31. bool(false)
  32. string(1) "."
  33. string(1) "."