bug78340.phpt 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. --TEST--
  2. Bug #78340: Include of stream wrapper not reading whole file
  3. --FILE--
  4. <?php
  5. class lib {
  6. public static $files= [];
  7. private $bytes, $pos;
  8. function stream_open($path, $mode, $options, $opened_path) {
  9. $this->bytes= self::$files[$path];
  10. $this->pos= 0;
  11. $this->ino= crc32($path);
  12. return true;
  13. }
  14. function stream_read($count) {
  15. $chunk= substr($this->bytes, $this->pos, $count);
  16. $this->pos+= strlen($chunk);
  17. return $chunk;
  18. }
  19. function stream_eof() {
  20. return $this->pos >= strlen($this->bytes);
  21. }
  22. function stream_close() {
  23. $this->bytes= null;
  24. }
  25. function stream_stat() {
  26. return [
  27. 'dev' => 3632233996,
  28. 'size' => strlen($this->bytes),
  29. 'ino' => $this->ino
  30. ];
  31. }
  32. function stream_set_option($option, $arg1, $arg2) {
  33. return false;
  34. }
  35. }
  36. $fill = str_repeat('.', 8192);
  37. lib::$files['lib://test.php']= '<?php /* '.$fill.' */ function test() { echo "Works!\n"; }';
  38. stream_wrapper_register('lib', lib::class);
  39. include('lib://test.php');
  40. test();
  41. ?>
  42. --EXPECT--
  43. Works!