|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16689 bzread has no reliable way of detecting eof
Submitted: 2002-04-18 17:29 UTC Modified: 2002-08-30 01:00 UTC
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: joshbuddy at hotmail dot com Assigned:
Status: No Feedback Package: Bzip2 Related
PHP Version: 4.1.2 OS: win32
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: joshbuddy at hotmail dot com
New email:
PHP Version: OS:


 [2002-04-18 17:29 UTC] joshbuddy at hotmail dot com
obviously feof will not work on a Bz file handle (though it would be nice if it did)

the only way i could find it detect the end in a loop (where you would be slurping in the whole file) is:

// open the file ... $bzfile

while ($string!=str_repeat("\0",4096)) {

a better mechanism for eof detection is needed


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-18 18:35 UTC]
Try a recent CVS snapshot; you can now use feof on bz handles.
Reopen this report if it doesn't work for you :-)
 [2002-04-18 18:41 UTC]
Err, scratch that last comment; the only way to detect eof
for bzip streams is to keep reading it.
feof will always return false for bz2.
Your bzread or fread call should return false when no more data can be read.
while(($string = bzread($bzfile, 4096)) !== false) {
should do what you want.
 [2002-04-19 23:32 UTC] joshbuddy at hotmail dot com
this does not work on win32. bzread gives back a string of \0 as long as the bzread requested...

and in php "\0\0\0" != false

i'm going to reopen and mark it as a win32 bug until there is confirmation.. good luck.
 [2002-04-20 05:55 UTC]
Can you try a CVS snapshot?
I've double checked the code: in the CVS version,
bzread will return a zero-length string when there is
no more data, fread will return false.
If you are still seeing a 4K long string of zeroes,
then that is a bug in the win32 bz2 library.

 [2002-08-30 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Sep 23 15:01:24 2023 UTC