summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-09-28 18:54:18 -0400
committerNick Mathewson <nickm@torproject.org>2017-09-28 18:54:18 -0400
commit411074501789d742b412034a9299c8e3d0569347 (patch)
tree21644042f6a0b2d8615e0c10da83a79596011e61
parent3a073c463dbade2171a1a6ec1558bd81c0ff27f9 (diff)
parent82f109c2b3cf159cd3329c4c575d737cff8e2c59 (diff)
downloadtor-411074501789d742b412034a9299c8e3d0569347.tar.gz
tor-411074501789d742b412034a9299c8e3d0569347.zip
Merge branch 'maint-0.3.1'
-rw-r--r--changes/bug235513
-rw-r--r--src/common/compress.c7
2 files changed, 10 insertions, 0 deletions
diff --git a/changes/bug23551 b/changes/bug23551
new file mode 100644
index 0000000000..2f918bfa3a
--- /dev/null
+++ b/changes/bug23551
@@ -0,0 +1,3 @@
+ o Minor bugfixes (compression):
+ - Handle a pathological case when decompressing Zstandard data when the
+ output buffer size is zero. Fixes bug 23551; bugfix on 0.3.1.1-alpha.
diff --git a/src/common/compress.c b/src/common/compress.c
index c13a3b0aed..f178915467 100644
--- a/src/common/compress.c
+++ b/src/common/compress.c
@@ -547,6 +547,13 @@ tor_compress_process(tor_compress_state_t *state,
const size_t out_len_orig = *out_len;
tor_compress_output_t rv;
+ if (*out_len == 0 && (*in_len > 0 || finish)) {
+ // If we still have input data, but no space for output data, we might as
+ // well return early and let the caller do the reallocation of the out
+ // variable.
+ return TOR_COMPRESS_BUFFER_FULL;
+ }
+
switch (state->method) {
case GZIP_METHOD:
case ZLIB_METHOD: