Bug #78340 [Ver->Csd]: Include of stream wrapper not reading whole file
| From: | nikic@php.net | Date: | Mon, 29 Jul 2019 08:13:06 +0000 |
| Subject: | Bug #78340 [Ver->Csd]: Include of stream wrapper not reading whole file | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-221970@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=78340&edit=1
ID: 78340
Updated by: nikic@php.net
Reported by: thekid@php.net
Summary: Include of stream wrapper not reading whole file
-Status: Verified
+Status: Closed
Type: Bug
Package: Scripting Engine problem
Operating System: Windows
PHP Version: 7.4-snapshot
Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=9bfda013d308b47610fb23ee565500418a9f3cde
Log: Fixed bug #78340
Previous Comments:
------------------------------------------------------------------------
[2019-07-29 07:49:50] nikic@php.net
Sorry, I missed the fact that there is a CLI arg.
------------------------------------------------------------------------
[2019-07-29 07:47:50] nikic@php.net
On linux this prints "Works!" for me (checked with and without opcache).
------------------------------------------------------------------------
[2019-07-28 11:51:53] thekid@php.net
It works up until https://windows.php.net/downloads/snaps/php-7.4/rb317f0e/
- maybe the cause is in https://github.com/php/php-src/commit/d59aac58b3e7da7ad01a194fe9840d89725ea229
------------------------------------------------------------------------
[2019-07-28 11:24:53] thekid@php.net
Correct metadata
------------------------------------------------------------------------
[2019-07-28 11:19:51] thekid@php.net
Description:
------------
When reading files from a stream wrapper, not all bytes are read.
Test script:
---------------
<?php
class lib {
public static $files= [];
private $bytes, $pos;
function stream_open($path, $mode, $options, $opened_path) {
$this->bytes= self::$files[$path];
$this->pos= 0;
$this->ino= crc32($path);
return true;
}
function stream_read($count) {
$chunk= substr($this->bytes, $this->pos, $count);
$this->pos+= strlen($chunk);
return $chunk;
}
function stream_eof() {
return $this->pos >= strlen($this->bytes);
}
function stream_close() {
$this->bytes= null;
}
function stream_stat() {
return [
'dev' => 3632233996,
'size' => strlen($this->bytes),
'ino' => $this->ino
];
}
function stream_set_option($option, $arg1, $arg2) {
return false;
}
}
$fill= str_repeat('.', $argv[1] ?? 0);
lib::$files['lib://test.php']= '<?php /* '.$fill.' */ function test() {
echo "Works!\n"; }';
stream_wrapper_register('lib', lib::class);
include('lib://test.php');
test();
Expected result:
----------------
$ /cygdrive/c/tools/php-7.3.6-nts-Win32-VC15-x64/php wrapper.php 8192
Works!
Actual result:
--------------
$ /cygdrive/c/tools/php-7.4snap-nts-windows-vc15-x64/php wrapper.php 8192
Warning: Unterminated comment starting line 1 in lib://test.php on line 1
Fatal error: Uncaught Error: Call to undefined function test() in
C:\tools\cygwin\home\Timm\devel\xp\core\wrapper.php:47
Stack trace:
#0 {main}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=78340&edit=1