[tor-commits] [tor/master] Expose `tor_compress_is_compression_bomb()` as part of the public compression API.

nickm at torproject.org nickm at torproject.org
Tue Apr 25 12:18:24 UTC 2017


commit e6c6606a17841eaf263967254990db5e9443942d
Author: Alexander Færøy <ahf at torproject.org>
Date:   Tue Apr 18 03:12:19 2017 +0200

    Expose `tor_compress_is_compression_bomb()` as part of the public compression API.
    
    This patch exposes the old `is_compression_bomb()` function as a public
    API as part of the compression module.
    
    See https://bugs.torproject.org/21663
---
 src/common/torgzip.c | 8 ++++----
 src/common/torgzip.h | 3 +++
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/common/torgzip.c b/src/common/torgzip.c
index 09f3806..d6f6225 100644
--- a/src/common/torgzip.c
+++ b/src/common/torgzip.c
@@ -105,10 +105,10 @@ method_bits(compress_method_t method, compression_level_t level)
 #define CHECK_FOR_COMPRESSION_BOMB_AFTER (1024*64)
 /** @} */
 
-/** 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. */
-static int
-is_compression_bomb(size_t size_in, size_t size_out)
+/** 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)
 {
   if (size_in == 0 || size_out < CHECK_FOR_COMPRESSION_BOMB_AFTER)
     return 0;
diff --git a/src/common/torgzip.h b/src/common/torgzip.h
index 8f2363a..fa56628 100644
--- a/src/common/torgzip.h
+++ b/src/common/torgzip.h
@@ -49,6 +49,9 @@ compress_method_t detect_compression_method(const char *in, size_t in_len);
 int
 tor_compress_memory_level(compression_level_t level);
 
+int
+tor_compress_is_compression_bomb(size_t size_in, size_t size_out);
+
 /** Return values from tor_compress_process; see that function's documentation
  * for details. */
 typedef enum {





More information about the tor-commits mailing list