summaryrefslogtreecommitdiff
path: root/src/common/compress.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/compress.c')
-rw-r--r--src/common/compress.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/common/compress.c b/src/common/compress.c
index beeff5fcb8..bc12a58ad6 100644
--- a/src/common/compress.c
+++ b/src/common/compress.c
@@ -51,8 +51,8 @@ static atomic_counter_t total_compress_allocation;
/** Return true if uncompressing an input of size <b>in_size</b> to an input of
* size at least <b>size_out</b> looks like a compression bomb. */
-int
-tor_compress_is_compression_bomb(size_t size_in, size_t size_out)
+MOCK_IMPL(int,
+tor_compress_is_compression_bomb,(size_t size_in, size_t size_out))
{
if (size_in == 0 || size_out < CHECK_FOR_COMPRESSION_BOMB_AFTER)
return 0;
@@ -164,7 +164,7 @@ tor_compress_impl(int compress,
goto err;
}
if (out_alloc >= SIZE_T_CEILING / 2) {
- log_warn(LD_GENERAL, "While %scompresing data: ran out of space.",
+ log_warn(LD_GENERAL, "While %scompressing data: ran out of space.",
compress?"":"un");
goto err;
}
@@ -185,11 +185,12 @@ tor_compress_impl(int compress,
}
case TOR_COMPRESS_ERROR:
log_fn(protocol_warn_level, LD_GENERAL,
- "Error while %scompresing data: bad input?",
+ "Error while %scompressing data: bad input?",
compress?"":"un");
goto err; // bad data.
- default:
+
// LCOV_EXCL_START
+ default:
tor_assert_nonfatal_unreached();
goto err;
// LCOV_EXCL_STOP
@@ -561,9 +562,9 @@ tor_compress_process(tor_compress_state_t *state,
finish);
break;
case LZMA_METHOD:
- rv =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:
rv = tor_zstd_compress_process(state->u.zstd_state,
@@ -581,6 +582,12 @@ tor_compress_process(tor_compress_state_t *state,
if (BUG((rv == TOR_COMPRESS_OK) &&
*in_len == in_len_orig &&
*out_len == out_len_orig)) {
+ log_warn(LD_GENERAL,
+ "More info on the bug: method == %s, finish == %d, "
+ " *in_len == in_len_orig == %lu, "
+ "*out_len == out_len_orig == %lu",
+ compression_method_get_human_name(state->method), finish,
+ (unsigned long)in_len_orig, (unsigned long)out_len_orig);
return TOR_COMPRESS_ERROR;
}