if userspace stream is present, fread() reads in 8192 max, otherwise it works
| Bug #37158 | if userspace stream is present, fread() reads in 8192 max, otherwise it works | ||||
|---|---|---|---|---|---|
| Submitted: | 2006-04-21 22:11 UTC | Modified: | 2006-04-22 17:18 UTC | ||
| From: | cellog@php.net | Assigned: | wez (profile) | ||
| Status: | Closed | Package: | Streams related | ||
| PHP Version: | 5CVS-2006-04-21 (CVS) | OS: | n/a | ||
| Private report: | No | CVE-ID: | None | ||
[2006-04-21 22:11 UTC] cellog@php.net
Description: ------------ fread($fp, 20000); will read in 20000 bytes from a local file, but is a userspace stream is defined anywhere, it will only read in 8192 bytes, without any warning or error. This is actually similar to Bug #30936, but as I say the problem here is that the presence of a userspace stream handler changes the behavior of fread() - any indeterminate behavior is bad. I wonder if the fix from #32810 could be helpful for this problem as well? Reproduce code: --------------- <?php // paste in the stream code from the example in the manual // be sure to include stream_wrapper_register error_reporting(E_ALL | E_STRICT); $file = dirname(__FILE__) . '/footest.txt'; $x = str_repeat('1', 8192); $fp = fopen($file, 'w'); for ($i = 0; $i < 5; $i++) { fwrite($fp, $x); } fclose($fp); $fp = fopen($file, 'r'); $outsidecontents = fread($fp, 20000); fclose($fp); var_dump('size of contents 1 = ' . strlen($outsidecontents)); $outsidecontents = file_get_contents($file); var_dump('size of contents 2 = ' . strlen($outsidecontents)); ?> Expected result: ---------------- string(26) "size of contents 1 = 20000" string(26) "size of contents 2 = 40960" Actual result: -------------- string(25) "size of contents 1 = 8192" string(26) "size of contents 2 = 40960"
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2006-04-21 22:15 UTC] cellog@php.net
[2006-04-21 22:40 UTC] pajoye@php.net
[2006-04-22 04:25 UTC] cellog@php.net
[2006-04-22 15:36 UTC] wez@php.net
[2006-04-22 17:18 UTC] wez@php.net