zlib uncompress returns -5 on Ubuntu 10.10 x64 (g++ -m64)
I use python and zlib 开发者_StackOverflow社区to compress a buffer, and I uncompress it in a C++ program.
If I build the program with g++ -m32, I can uncompress the buffer.
If I build it with g++ -m64 (and link with the same option), it returns -5 (Z_BUF_ERROR).
Can I fix it ? Should I change the size of my buffer ?
I allocate my output buffer with the exact size, should I align it on 64 bits or something ?
Thanks.
I recently ran into this kind of problems. We had a software running fine when compiled in 32bits (even if run on a 64bits system) but returning the same Z_BUF_ERROR from uncompress() when compiling it for 64bits environment (using -m64)
The compressed data was carefully checked: read from a compressed file by the software then dumped in a file again and then compared, no differences.
So my conclusion was the problem was coming from the zlib itself. Ubuntu 10.4 repositories seem to only provide zlib version 1.2.3. The zlib home page provides version 1.2.5 (with some notes about better portability).
Hope it helps.
edit: We moved from using uncompress() to inflate() and it fixed our problem for 64bits architecture. We still don't know if uncompress() is working for 64bits systems with newer (>1.2.3) version of zlib thus. But this workaround is ok if using zlib-1.2.3 / 64bits.
I had the same problem. It was because I was passing a reference to an int as second parameter of uncompress ( destLen ). This led to an incorrect value inside the uncompress function because of the expansion to uLong (8 bytes instead of 4). Using an uLong variable reference for the destLen parameter solved all problems
精彩评论