diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-06-20 20:26:45 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-06-20 20:26:45 -0400 |
commit | c999e84436a5f7ba1964abd4ae502212f0995bcb (patch) | |
tree | dcaae22c35169275f1202e7b254444a9154310c0 /src | |
parent | c4152a25e354b3408570603c8481302bf986f65c (diff) | |
parent | 9328bd524e38befe240fd729a9febb4dfe8b5be4 (diff) | |
download | tor-c999e84436a5f7ba1964abd4ae502212f0995bcb.tar.gz tor-c999e84436a5f7ba1964abd4ae502212f0995bcb.zip |
Merge branch 'bug22672_031' into maint-0.3.1
Diffstat (limited to 'src')
-rw-r--r-- | src/common/compress.c | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/src/common/compress.c b/src/common/compress.c index c16d1b51ee..46aa1d52ba 100644 --- a/src/common/compress.c +++ b/src/common/compress.c @@ -548,28 +548,42 @@ tor_compress_process(tor_compress_state_t *state, int finish) { tor_assert(state != NULL); + const size_t in_len_orig = *in_len; + const size_t out_len_orig = *out_len; + tor_compress_output_t rv; switch (state->method) { case GZIP_METHOD: case ZLIB_METHOD: - return tor_zlib_compress_process(state->u.zlib_state, - out, out_len, in, in_len, - finish); + rv = tor_zlib_compress_process(state->u.zlib_state, + out, out_len, in, in_len, + finish); + break; case LZMA_METHOD: - return tor_lzma_compress_process(state->u.lzma_state, - out, out_len, in, in_len, - finish); + rv =tor_lzma_compress_process(state->u.lzma_state, + out, out_len, in, in_len, + finish); + break; case ZSTD_METHOD: - return tor_zstd_compress_process(state->u.zstd_state, - out, out_len, in, in_len, - finish); + rv = tor_zstd_compress_process(state->u.zstd_state, + out, out_len, in, in_len, + finish); + break; case NO_METHOD: - return tor_cnone_compress_process(out, out_len, in, in_len, - finish); + rv = tor_cnone_compress_process(out, out_len, in, in_len, + finish); + break; + default: case UNKNOWN_METHOD: goto err; } + if (BUG((rv == TOR_COMPRESS_OK) && + *in_len == in_len_orig && + *out_len == out_len_orig)) { + return TOR_COMPRESS_ERROR; + } + return rv; err: return TOR_COMPRESS_ERROR; } |