php.net |  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
Votes:1
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
Have you experienced this issue?
Rate the importance of this bug to you:

 [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

$data="";
$string=bzread($bzfile,4096);
while ($string!=str_repeat("\0",4096)) {
   $data.=$string;
   $string=bzread($bzfile,4096);
}

a better mechanism for eof detection is needed

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-18 18:35 UTC] wez@php.net
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] wez@php.net
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] wez@php.net
Can you try a CVS snapshot?
Try: http://php-bin-snaps.sourceforge.net/
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-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 04:01:29 2024 UTC