title: Cannot inflate content from older zlib library
body: <p>Heyo,</p>
  
  <p>I have two versions of a networking library - one original where source code was lost - and mine, which is a newer implementation. In my newer one, I was using zlib 1.2.5, then updated to 1.2.11.</p>
  
  <p>This upgrade broke the compression entirely. The newer library can no longer understand output of older one, and vice versa. Since there will be readers with both my version and the old version of the networking library, that's not suitable.</p>
  
  <p>I have confirmed that the (compressed) message bytes are as expected; correct size and data, bytes unchanged from what was sent. I've compared them in a hex editor just to be sure. My only conclusion is that there has been something changed about the library.</p>
  
  <hr>
  
  <p>A test input is: "This is a test binary message." (ASCII, with null byte terminator)</p>
  
  <p>Result from old library (possibly zlib 1.1.3):</p>
  
  <pre><code>00000000: 1f00 0000 789c 0bc9 c82c 5600 a244 8592  ....x....,V..D..
  00000010: d4e2 1285 a4cc bcc4 a24a 85dc d4e2 e2c4  .........J......
  00000020: f454 3d06 00af cc0a ce                   .T=......
  </code></pre>
  
  <p>Result from new library (zlib 1.2.11):</p>
  
  <pre><code>00000000: 78da 0bc9 c82c 5600 a244 8592 d4e2 1285  x....,V..D......
  00000010: a4cc bcc4 a24a 85dc d4e2 e2c4 f454 3d06  .....J.......T=.
  00000020: 00af cc0a ce                             .....
  </code></pre>
  
  <p>Decompression produces either "invalid block type", or "incorrect header check".</p>
  
  <p>To produce the same compressed result, I've tried following <a href="https://stackoverflow.com/a/22311297/6442596">this post</a> which recommends messing with MAX_WBITS, but MAX_WBITS, -MAX_WBITS, and MAX_WBITS + 16 still result in Z_DATA_ERROR and wrong output sizes (37, 31, and 49 bytes respectively).</p>
  
  <p>I'm not sure if it's deflate or zlib, I checked <a href="https://stackoverflow.com/a/19127748/6442596">this post</a> but none of them seem to fully match (closest is .z). The documentation says "zlib", but since it's a single block of binary send as a message, I think it's more likely to use raw deflate.</p>
  
  <hr>
  
  <p>Any advise on what could cause this would be appreciated. Oh, and <a href="https://pastebin.com/13hTjwHw" rel="nofollow noreferrer">here's my code</a>.</p>