Note that there are some explanatory texts on larger screens.

plurals
  1. POZlib uncompress returns Z_DATA_ERROR
    primarykey
    data
    text
    <p>I am working on a client server application, where client compresses a 2MB data sends to the server, server receives the data uncompresses it and writes it to a file. </p> <p>For some packets uncompression was failing and I added MD5 sum to both client side and server side code and also debugged using uncompression at the client side after compressing the data. The same parameters that passes for uncompress function in client side is failing with Z_DATA_ERROR in the server side. The data's MD5sum seems same. Am totally clueless what I could do next. </p> <p>Server Side cod looks like this:</p> <pre><code>int ret = uncompress((Bytef*)unCompressedBuffer, &amp;dwUncompressedBytes, (const Bytef*) receivedBuffer+525, dwBlockLength); if (ret == Z_OK) { } else { std::cout &lt;&lt; " Uncompression failed for Block: " &lt;&lt; iBlock &lt;&lt; std::endl; std::cout &lt;&lt; " PacketType: 4" &lt;&lt; " Block Number:" &lt;&lt; iBlock &lt;&lt; " Length:" &lt;&lt; dwBlockLength &lt;&lt; "Error:" &lt;&lt; ret &lt;&lt; std::endl; PrintMD5SumResult((PBYTE)receivedBuffer+525, compressedSize-525); std::cout &lt;&lt; " Uncompressed MD5 Checksum:0"; PrintMD5SumResult((PBYTE)unCompressedBuffer, dwUncompressedBytes); } } </code></pre> <p>Client Code Looks like this:</p> <pre><code>int ret = compress2(l_pCompressData + 4, &amp;destLen, (const Bytef*) pBlockData, dwBlockSize, 6); memcpy(m_pWriteBuffer+525, l_pCompressData, destLen); m_dwWriteBytes = destLen+525; std::cout &lt;&lt; " \n Compressed MD5 Sum:0"; PrintMD5SumResult(m_pWriteBuffer, m_dwWriteBytes); PrintMD5SumResult(m_pWriteBuffer+525, m_dwWriteBytes-525); int ret = uncompress(m_pUnCompressData, &amp;uncomLen, (const Bytef*)m_pWriteBuffer+525, destLen); if(ret != Z_OK) { std::cout &lt;&lt; " Uncompression has failed." &lt;&lt; std::endl; } else { //std::cout &lt;&lt; " UnCompressed MD5 Sum:0"; //PrintMD5SumResult((PBYTE)m_pUnCompressData, md5Output, dwBlockSize); } // Write the 2MB to the network WriteDataOverNetwork(m_NetworkStream, m_pWriteBuffer, m_dwWriteBytes, &amp;dwNumBytes, TRUE); </code></pre> <p>I narrowed down the problem to the following piece of code in zlib - but have a hard time understanding it. In the inflate() function, (ZSWAP32(hold)) != state->check) this statement is failing. Can someone help me out here? MD5sum used here is from Boton C++ library. </p> <pre><code> case CHECK: if (state-&gt;wrap) { NEEDBITS(32); out -= left; strm-&gt;total_out += out; state-&gt;total += out; if (out) strm-&gt;adler = state-&gt;check = UPDATE(state-&gt;check, put - out, out); out = left; if (( #ifdef GUNZIP state-&gt;flags ? hold : #endif ZSWAP32(hold)) != state-&gt;check) { strm-&gt;msg = (char *)"incorrect data check"; state-&gt;mode = BAD; break; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload