[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ft-devel] Modification in FT_Gzip_Uncompress
From: |
Werner LEMBERG |
Subject: |
Re: [ft-devel] Modification in FT_Gzip_Uncompress |
Date: |
Sat, 08 Jun 2019 17:40:28 +0200 (CEST) |
> In OpenType fonts, SVG documents can be either in plain text or gzip
> encoded.
>
> While writing the code to read these documents I looked for a
> function which could do gzip decoding inside FreeType. That's when
> I found `FT_Gzip_Uncompress'. Using it, I realized it didn't work
> as expected and returned errors.
>
> After using zlib in a separate program on the same data I figured
> out the problem. Zlib data can be encoded with both `gzip' and
> `zlib' encoded wrapper. AFAIK, by default, it looks for only `zlib'
> wrapper. The current call to `inflateInit2' is:
>
> 749| err = inflateInit2( &stream, MAX_WBITS );
>
> `MAX_WBITS' is 15. Thus, it only looks for `zlib' wrapper and in
> case of gzip compressed SVGs, returns error when `inflate' is
> called. The fix is to replace it with:
>
> 749| err = inflateInit2( &stream, MAX_WBITS|32 );
>
> This enables both `gzip' and `zlib' decoding with automatic header
> detection. Solving my problem.
Great!
> This solves it for me and I HOPE this won't cause cause any previous
> code relying on `FT_Gzip_Uncompress' to fail. Let me know if there
> are easy tests to check that.
>
> Let me know if this is the right change and can also be made in
> master later on, meaning I can rely on it. :)
Please prepare a patch for master. In case there are problems I guess
that the FreeType fuzzers will catch them, probably unveiling hidden
bugs.
Werner