diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-09-28 12:20:02 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-09-28 12:20:02 -0400 |
commit | 3a073c463dbade2171a1a6ec1558bd81c0ff27f9 (patch) | |
tree | 28d329ccf721ef02e2e7973337b94e84fc88d3f2 /src/common | |
parent | 14614a592e43e2a6fcddb79c3f4ff5c8df60f380 (diff) | |
download | tor-3a073c463dbade2171a1a6ec1558bd81c0ff27f9.tar.gz tor-3a073c463dbade2171a1a6ec1558bd81c0ff27f9.zip |
Improve unit test coverage for compression code.
These tests try uncompressing garbage, verify that we won't
make compression bombs, and verify that we won't uncompress
compression bombs.
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/compress.c | 4 | ||||
-rw-r--r-- | src/common/compress.h | 3 |
2 files changed, 4 insertions, 3 deletions
diff --git a/src/common/compress.c b/src/common/compress.c index 520148f83d..c13a3b0aed 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; diff --git a/src/common/compress.h b/src/common/compress.h index ecb20668e4..23a9817479 100644 --- a/src/common/compress.h +++ b/src/common/compress.h @@ -45,7 +45,8 @@ int tor_uncompress(char **out, size_t *out_len, compress_method_t detect_compression_method(const char *in, size_t in_len); -int tor_compress_is_compression_bomb(size_t size_in, size_t size_out); +MOCK_DECL(int,tor_compress_is_compression_bomb,(size_t size_in, + size_t size_out)); int tor_compress_supports_method(compress_method_t method); unsigned tor_compress_get_supported_method_bitmask(void); |