php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #44893 gzfile() does not load complete GIF file
Submitted: 2008-05-02 16:31 UTC Modified: 2020-09-22 14:54 UTC
From: sworddragon2 at aol dot com Assigned: cmb (profile)
Status: Closed Package: Zlib related
PHP Version: 5CVS, 6CVS (2008-10-30) OS: Windows XP Professional SP3
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: sworddragon2 at aol dot com
New email:
PHP Version: OS:

 

 [2008-05-02 16:31 UTC] sworddragon2 at aol dot com
Description:
------------
If im trying to use the function gzfile() to a compressed file, that
includes just a picture, the function don't read the complete file. On
this reproduce, the function stops after the End Transmission Block.

Reproduce code:
---------------
$file=fopen("smiley1.gif","rb");
$picture=fread($file,filesize("smiley1.gif"));
fclose($file);
$file=gzopen("smiley1.gz","w");
gzwrite($file,$picture);
gzclose($file);
$file=gzfile("smiley1.gz");
print_r($file);

Expected result:
----------------
I expect to see all arrays until the end of the file.

Actual result:
--------------
With gzfile, i got just the array [0] with the content GIF89a

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-05-02 20:49 UTC] fa@php.net
Couldn't reproduce on Win XP SP2 with php-5.2.6-Win32.zip
 [2008-05-02 21:19 UTC] sworddragon2 at aol dot com
I used this picture for the example:

http://img501.imageshack.us/img501/7006/smiley1dr6.gif


Maybe it helps you to reproduce the problem. But this was not the only picture with that I can reproduce the problem.
 [2008-05-06 11:08 UTC] kalle@php.net
Im able to re-produce this on Windows XP SP2 using the image you supplied aswell as with other files would return odd strings
 [2008-10-29 17:29 UTC] sworddragon2 at aol dot com
I tested it with the 5.2.7RC2-dev and the 5.3.0alpha3-dev from your link, but the bug isn't fixed. In both versions, Firefox 3.0.3 gives me an output of:

Array
(
    [0] => GIF89a
)

It breaks again after the End Transmission Block. I used the same picture again.
 [2008-10-30 17:14 UTC] jani@php.net
What actually is the bug here? You're concatenating same image in same file and expect..what?
 [2008-10-30 17:15 UTC] jani@php.net
$file=gzopen("smiley1.gz","w");

I think that should also be "wb" under windows..
 [2008-11-02 23:13 UTC] sworddragon2 at aol dot com
I tried it with wb, but it doesn't help.

The problem is, that gzfile stops the read process after 7/132 byte. The read process is breaking after gzfile reads the ETB (End Transmission Block), which is the seventh char of this picture.
 [2008-11-21 17:57 UTC] jani@php.net
gzfile() is not binary-safe. So the behaviour here isn't really unexpected. Anyway, you're better of using gzread() instead when dealing with binary files.
 [2011-04-08 20:55 UTC] jani@php.net
-Package: Feature/Change Request +Package: Zlib related
 [2020-09-22 14:54 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2020-09-22 14:54 UTC] cmb@php.net
gzfile() is for reading compressed *text* files.  However, GIF
files are no text files.  This feature request doesn't make any
sense to me.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 14:01:29 2024 UTC