]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Logging / Compression
authorWaldemar Zimpel <w.zimpel@dev.utilizer.de>
Thu, 14 Aug 2025 21:41:27 +0000 (23:41 +0200)
committerWaldemar Zimpel <w.zimpel@dev.utilizer.de>
Thu, 14 Aug 2025 22:13:05 +0000 (00:13 +0200)
Add compression factor to the "Detected possible compression bomb ..."
warning.

src/lib/compress/compress.c

index 346e77f07d9f43dceef544da4faedd8965c84605..b7fedcd6af133445c18570f9de678e73e47defa8 100644 (file)
@@ -66,11 +66,13 @@ 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;
 
-  if (size_out / size_in > MAX_UNCOMPRESSION_FACTOR) {
+  double compression_factor = (double)size_out / size_in;
+  if (compression_factor > 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);
+             "input size = %"TOR_PRIuSZ" and output size = %"TOR_PRIuSZ" "
+             "(compression factor = %.2f)",
+             size_in, size_out, compression_factor);
     return 1;
   }