diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/compress.c | 44 | ||||
-rw-r--r-- | src/common/compress_none.c | 2 |
2 files changed, 30 insertions, 16 deletions
diff --git a/src/common/compress.c b/src/common/compress.c index c6c3897989..7926faaa60 100644 --- a/src/common/compress.c +++ b/src/common/compress.c @@ -105,8 +105,8 @@ tor_compress_impl(int compress, if (stream == NULL) { log_warn(LD_GENERAL, "NULL stream while %scompressing", compress?"":"de"); - log_debug(LD_GENERAL, "method: %d level: %d at len: %zd", - method, compression_level, in_len); + log_debug(LD_GENERAL, "method: %d level: %d at len: %lu", + method, compression_level, (unsigned long)in_len); return -1; } @@ -146,8 +146,8 @@ tor_compress_impl(int compress, "Unexpected %s while %scompressing", complete_only?"end of input":"result", compress?"":"de"); - log_debug(LD_GENERAL, "method: %d level: %d at len: %zd", - method, compression_level, in_len); + log_debug(LD_GENERAL, "method: %d level: %d at len: %lu", + method, compression_level, (unsigned long)in_len); goto err; } else { if (in_len == 0) { @@ -542,28 +542,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; } diff --git a/src/common/compress_none.c b/src/common/compress_none.c index b76e6010ec..34314e4af7 100644 --- a/src/common/compress_none.c +++ b/src/common/compress_none.c @@ -4,7 +4,7 @@ /* See LICENSE for licensing information */ /** - * \file compress_lzma.c + * \file compress_none.c * \brief Compression backend for identity compression. * * We actually define this backend so that we can treat the identity transform |