diff options
author | David Goulet <dgoulet@torproject.org> | 2023-09-18 09:10:44 -0400 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2023-09-18 09:10:44 -0400 |
commit | cb036351c02f398e04472edb9932312c312962b0 (patch) | |
tree | cc6c8ecf05d1f930f27d8beec15fb4d6f7299131 | |
parent | 8ef30841acf1076f5e7d2fd61548e5bc9d4288ed (diff) | |
parent | cd2bc94c44c5b01044105ab4bd844e84bf2b163e (diff) | |
download | tor-cb036351c02f398e04472edb9932312c312962b0.tar.gz tor-cb036351c02f398e04472edb9932312c312962b0.zip |
Merge branch 'maint-0.4.8' into release-0.4.8
-rw-r--r-- | changes/ticket40739 | 3 | ||||
-rw-r--r-- | src/lib/compress/compress.c | 10 | ||||
-rw-r--r-- | src/test/test_util.c | 2 |
3 files changed, 13 insertions, 2 deletions
diff --git a/changes/ticket40739 b/changes/ticket40739 new file mode 100644 index 0000000000..f60bfc5d87 --- /dev/null +++ b/changes/ticket40739 @@ -0,0 +1,3 @@ + o Minor features (debugging, compression): + - Log the input and output buffer sizes when we detect a potential + compression bomb. Diagnostic for ticket 40739. diff --git a/src/lib/compress/compress.c b/src/lib/compress/compress.c index 83e63905cc..346e77f07d 100644 --- a/src/lib/compress/compress.c +++ b/src/lib/compress/compress.c @@ -66,7 +66,15 @@ 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; - return (size_out / size_in > MAX_UNCOMPRESSION_FACTOR); + if (size_out / size_in > MAX_UNCOMPRESSION_FACTOR) { + log_warn(LD_GENERAL, + "Detected possible compression bomb with " + "input size = %"TOR_PRIuSZ " and output size = %"TOR_PRIuSZ, + size_in, size_out); + return 1; + } + + return 0; } /** Guess the size that <b>in_len</b> will be after compression or diff --git a/src/test/test_util.c b/src/test/test_util.c index 1dae2c617e..391c3d07c1 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -2945,7 +2945,7 @@ test_util_gzip_compression_bomb(void *arg) tt_int_op(-1, OP_EQ, tor_compress(&result, &result_len, one_mb, one_million, ZLIB_METHOD)); - expect_single_log_msg_containing( + expect_log_msg_containing( "We compressed something and got an insanely high " "compression factor; other Tors would think this " "was a compression bomb."); |