]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Treat Z_BUF_ERROR as TOR_ZLIB_BUF_FULL when finalizing a zlib buffer
authorNick Mathewson <nickm@torproject.org>
Wed, 4 Jun 2014 00:38:00 +0000 (20:38 -0400)
committerNick Mathewson <nickm@torproject.org>
Wed, 3 Sep 2014 17:42:46 +0000 (13:42 -0400)
Otherwise, when we're out of input *and* finalizing, we might report
TOR_ZLIB_OK erroneously and not finalize the buffer.

(I don't believe this can happen in practice, with our code today:
write_to_buf_zlib ensures that we are never trying to write into a
completely empty buffer, and zlib says "Z_OK" if you give it even
one byte to write into.)

Fixes bug 11824; bugfix on 0.1.1.23 (06e09cdd47eaa8f7e90ce2).

changes/bug11824 [new file with mode: 0644]
src/common/torgzip.c

diff --git a/changes/bug11824 b/changes/bug11824
new file mode 100644 (file)
index 0000000..1eb89ca
--- /dev/null
@@ -0,0 +1,5 @@
+  o Minor bugfixes:
+    - When trying to finalize a zlib stream where we have already
+      exhausted all the input bytes and we need more bytes in the
+      output buffer, do not report the the write as successful.
+      Fixes bug 11824; bugfix on 0.1.1.23.
index 4328c63c8b02a58f6fce5564bd555b1f279b9540..778cbe9169f3702518fca6876068e622f906d0d6 100644 (file)
@@ -480,7 +480,7 @@ tor_zlib_process(tor_zlib_state_t *state,
     case Z_STREAM_END:
       return TOR_ZLIB_DONE;
     case Z_BUF_ERROR:
-      if (state->stream.avail_in == 0)
+      if (state->stream.avail_in == 0 && !finish)
         return TOR_ZLIB_OK;
       return TOR_ZLIB_BUF_FULL;
     case Z_OK: