realpath_bug77484.phpt 792 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. if (getenv('SKIP_REPEAT')) {
  13. /* The cwd is persistent across repeats */
  14. die("skip Not repeatable");
  15. }
  16. ?>
  17. --FILE--
  18. <?php
  19. $old_cwd = getcwd();
  20. mkdir(__DIR__ . "/foo");
  21. chdir(__DIR__ . "/foo");
  22. rmdir(__DIR__ . "/foo");
  23. // Outputs: / (incorrect)
  24. $new_cwd = getcwd();
  25. // Outputs: false (correct)
  26. $rp0 = realpath('');
  27. // Crash
  28. $rp1 = realpath('.');
  29. $rp2 = realpath('./');
  30. var_dump($old_cwd, $new_cwd, $rp0, $rp1, $rp2);
  31. ?>
  32. --EXPECTF--
  33. string(%d) "%s"
  34. bool(false)
  35. bool(false)
  36. string(1) "."
  37. string(1) "."