List Archive

Thread

Thread Index

Message

From: Thomas Klausner <tk%giga.or.at@localhost>
To: Sergei Hrushev <hrushev%gmail.com@localhost>
Subject: Re: Strange problem with zip_fopen_index/inflateInit2
Date: Mon, 23 May 2016 09:40:14 +0200

Hi Sergei!

I read your mail a couple of times, but don't see the problem either.
Can you build a debugging version of zlib and step into inflateInit2
to find out what exactly it errors out on?

Thanks,
 Thomas

On Thu, May 19, 2016 at 09:46:15AM +0600, Sergei Hrushev wrote:
> Hello!
> 
> I just compiled libzip in Visual Studio 2015 and now trying to check if all
> is OK.
> But this call seems to be always returning NULL for entries compressed via
> DEFLATE (I checking entry 0 only):
> 
> zf = zip_fopen_index(entry, 0, 0);
> 
> By tracing sources in debugger I found that the next line in
> zip_source_deflate.c returns -2:
> 
>  if ((ret=inflateInit2(&ctx->zstr, -MAX_WBITS)) != Z_OK) {
> 
> -2 is a Z_STREAM_ERROR
> 
> I checked on http://www.zlib.net/manual.html and it's written that
> Z_STREAM_ERROR is returned "if a parameters are invalid"
> 
> For example for entry 0 (named "compressable") of archive cm-default.zip
> (from libzip/regress)
> the value of ctx->zstr passed to inflateInit2 is as follows:
> 
> ctx->zstr    {next_in=0x00000000003f34d0 "KLD\x6" avail_in=5
> total_in=3452816845 ...}    z_stream_s
>         next_in        0x00000000003f34d0 "KLD\x6"    unsigned char *
>         avail_in    5    unsigned int
>         total_in    3452816845    unsigned long
>         next_out    0xcdcdcdcdcdcdcdcd <Error reading characters of
> string.>    unsigned char *
>         avail_out    3452816845    unsigned int
>         total_out    3452816845    unsigned long
>         msg            0x0000000000000000 <NULL>    char *
>         state        0xcdcdcdcdcdcdcdcd {dummy=??? }    internal_state *
>         zalloc        0x0000000000000000    void *(*)(void *, unsigned int,
> unsigned int)
>         zfree        0x0000000000000000    void(*)(void *, void *)
>         opaque        0x0000000000000000    void *
>         data_type    -842150451    int
>         adler        3452816845    unsigned long
>         reserved    3452816845    unsigned long
> 
> zlib website says "The fields next_in, avail_in, zalloc, zfree and opaque
> must be initialized before by the caller."
> It seems all these fields are initialized.
> 
> What else can be wrong in this structure?
> 
> P.S. I'm pretty sure zlib (1.2.8) itself works properly because libpng uses
> same lib file and works as expected.
> 
> Thank you very much in advance for any help!

Made by MHonArc.