diff options
author | Alexander Færøy <ahf@torproject.org> | 2023-09-13 16:13:28 +0200 |
---|---|---|
committer | Alexander Færøy <ahf@torproject.org> | 2023-09-13 16:13:28 +0200 |
commit | d9a6b37ab1597ac726e5f972ebfbccf024c58cbc (patch) | |
tree | 23b3f58f0e9762f2ff1f5a2f33b024dfba800490 /src/lib | |
parent | d6c89b1ae1b18cc3cae42638d7bbe1edd7e35715 (diff) | |
download | tor-d9a6b37ab1597ac726e5f972ebfbccf024c58cbc.tar.gz tor-d9a6b37ab1597ac726e5f972ebfbccf024c58cbc.zip |
Add diagnostic log message for compression bombs.
This patch causes `tor_compress_is_compression_bomb()` to emit a
warning-level log message that lets us learn the potential ratio of the
input to output buffer sizes. Hopefully, this will give us a bit of a
better idea whether the compression bomb ratio needs some tuning.
See: tpo/core/tor#40739.
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/compress/compress.c | 10 |
1 files changed, 9 insertions, 1 deletions
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 |