freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Devel] FreeType 2.1.4 unable to read some gzip'ed fonts [Patch by Alexi


From: Anthony Fok
Subject: [Devel] FreeType 2.1.4 unable to read some gzip'ed fonts [Patch by Alexis]
Date: Sun, 8 Jun 2003 14:04:17 +0800
User-agent: Mutt/1.5.4i

Dear all,

FreeType 2.1.4 was unable to read some gzip'ed fonts like
9x18-ISO8859-1.pcf.gz.  For the full story, please see Bug#184355
on the Debian Bug Tracking System:

        http://bugs.debian.org/184355

Many thanks to "Alexis S. L. Carvalho" <address@hidden> for
diagnosing and correcting the problem.  The following is his
patch and rationale.

----- Forwarded message from "Alexis S. L. Carvalho" <address@hidden> -----

Date: Fri, 30 May 2003 06:34:31 -0300
From: "Alexis S. L. Carvalho" <address@hidden>
Subject: Bug#184355: patch for bug #184355
To: Debian Bug Tracking System <address@hidden>

Hi

I believe the following patch for the function ft_gzip_file_fill_output
fixes bug #184355 (Works For Me(TM)).

--- freetype-2.1.4/freetype-2.1.4/src/gzip/ftgzip.c~gz-eof-fix  2003-05-28 
21:38:55.000000000 -0300
+++ freetype-2.1.4-alexis/freetype-2.1.4/src/gzip/ftgzip.c      2003-05-29 
18:56:20.000000000 -0300
@@ -378,7 +378,8 @@
       if ( err == Z_STREAM_END )
       {
         zip->limit = zstream->next_out;
-        error      = FT_Err_Invalid_Stream_Operation;
+        if ( zip->limit == zip->cursor )
+          error = FT_Err_Invalid_Stream_Operation;
         break;
       }
       else if ( err != Z_OK )

Rationale: the function ft_gzip_file_fill_output should return an error
on EOF only if no new data was read/uncompressed (well, I've never
programmed with zlib, but at least ft_gzip_file_skip_output and
ft_gzip_file_io use  zip->limit - zip->cursor  to calculate how much
data was uncompressed).

This function is called only by ft_gzip_file_skip_output and
ft_gzip_file_io.  Both functions break out of their reading loops
immediately when ft_gzip_file_fill_output returns an error.  The problem
is that zlib's inflate may have uncompressed more data even though it
returned Z_STREAM_END (again - I've never programmed with zlib).  The
end result is that these last two functions may end up ignoring part of
a file.


The line setting the error variable was originally added for revision
1.6 of this file - see
http://cvs.freetype.org/cgi-bin/viewcvs.cgi/freetype2/src/gzip/ftgzip.c#rev1.6

the relevant part of the commit message is:

    * src/gzip/ftgzip.c: fixed a bug that caused FreeType to loop endlessly
    when trying to read certain compressed gzip files. The following test
    could be used to reveal the bug:

       touch 0123456789 ; gzip 0123456789 ; ftdump 0123456789.gz

the above patch does _not_ reopen this bug - well, at least _this_ test
doesn't enter an infinite loop.

Hope this helps.

Alexis

----- End forwarded message -----

-- 
Anthony Fok Tung-Ling
ThizLinux Laboratory   <address@hidden> http://www.thizlinux.com/
Debian Chinese Project <address@hidden>       http://www.debian.org/intl/zh/
Come visit Our Lady of Victory Camp!           http://www.olvc.ab.ca/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]