bug38779_1.phpt 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. --TEST--
  2. Bug #38779 (engine crashes when require()'ing file with syntax error through userspace stream wrapper)
  3. --FILE--
  4. <?php
  5. class Loader {
  6. private $position;
  7. private $data;
  8. public function stream_open($path, $mode, $options, &$opened_path) {
  9. $this->data = '<' . "?php \n\"\";ll l\n ?" . '>';
  10. $this->position = 0;
  11. return true;
  12. }
  13. function stream_read($count) {
  14. $ret = substr($this->data, $this->position, $count);
  15. $this->position += strlen($ret);
  16. return $ret;
  17. }
  18. function stream_eof() {
  19. return $this->position >= strlen($this->data);
  20. }
  21. function stream_flush() {
  22. var_dump("flush!");
  23. }
  24. function stream_close() {
  25. @unlink(__DIR__."/bug38779.txt");
  26. var_dump("close!");
  27. }
  28. }
  29. stream_wrapper_register('Loader', 'Loader');
  30. $fp = fopen ('Loader://qqq.php', 'r');
  31. $filename = __DIR__."/bug38779.txt";
  32. $fp1 = fopen($filename, "w");
  33. fwrite($fp1, "<"."?php blah blah?".">");
  34. fclose($fp1);
  35. include $filename;
  36. echo "Done\n";
  37. ?>
  38. --CLEAN--
  39. <?php
  40. $filename = __DIR__."/bug38779.txt";
  41. if (file_exists($filename)) {
  42. @unlink(__DIR__."/bug38779.txt");
  43. }
  44. ?>
  45. --EXPECTF--
  46. Parse error: %s error%sin %s on line %d
  47. string(6) "close!"