stream_get_line unable to correctly identify the "ending" in the stream content
| Bug #44607 | stream_get_line unable to correctly identify the "ending" in the stream content | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2008-04-02 11:56 UTC | Modified: | 2008-11-03 23:38 UTC |
|
||||||||||
| From: | amoo_miki at yahoo dot com | Assigned: | ||||||||||||
| Status: | Closed | Package: | Streams related | |||||||||||
| PHP Version: | 5CVS, 6CVS (2008-08-19) | OS: | * | |||||||||||
| Private report: | No | CVE-ID: | None | |||||||||||
[2008-04-02 11:56 UTC] amoo_miki at yahoo dot com
Description: ------------ On some occasions stream_get_line acts weired by attempting the first seek without considering the "end of line" string. Below is the sample code that shows the problem with a workaround to temporarily solve the issue (that might ring some bells for the person who plans on fixing this). The code uses a small binary JPX file that can be fetched from http://barahmand.com/streambug/sample.txt Reproduce code: --------------- <?php $filename = 'sample.txt'; $arr = explode('<EndOfFrame>', file_get_contents($filename)); echo "Found in source at ".strlen($arr[0])."\n\n"; $fp = fopen($filename, "rb"); stream_get_line($fp, 15000, "<EndOfFrame>"); echo "Location in stream: ".ftell($fp)."\n"; echo "Rewinding...\n"; rewind($fp); stream_get_line($fp, 15000, "<EndOfFrame>"); echo "Location in stream: ".ftell($fp)."\n"; rewind($fp); echo "\nAttempting fix...\n"; stream_get_line($fp, 1, "<EndOfFrame>"); stream_get_line($fp, 15000, "<EndOfFrame>"); echo "Location in stream: ".ftell($fp)."\n"; echo "Rewinding...\n"; rewind($fp); stream_get_line($fp, 15000, "<EndOfFrame>"); echo "Location in stream: ".ftell($fp)."\n"; fclose($fp); ?> Expected result: ---------------- Found in source at 9295 Location in stream: 9307 Rewinding... Location in stream: 9307 Attempting fix... Location in stream: 9307 Rewinding... Location in stream: 9307 Actual result: -------------- Found in source at 9295 Location in stream: 15000 Rewinding... Location in stream: 15000 Attempting fix... Location in stream: 9307 Rewinding... Location in stream: 9307
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2008-07-14 21:45 UTC] amoo_miki at yahoo dot com
[2008-07-14 21:54 UTC] amoo_miki at yahoo dot com
[2008-08-19 15:30 UTC] amoo_miki at yahoo dot com
[2008-08-19 17:13 UTC] amoo_miki at yahoo dot com
[2008-11-03 23:38 UTC] lbarnaud@php.net