|
@@ -46,34 +46,16 @@
|
|
|
|
|
|
#include <zlib.h>
|
|
#include <zlib.h>
|
|
|
|
|
|
|
|
+#if defined ZLIB_VERNUM && ZLIB_VERNUM < 0x1200
|
|
|
|
+#error "We require zlib version 1.2 or later."
|
|
|
|
+#endif
|
|
|
|
+
|
|
static size_t tor_zlib_state_size_precalc(int inflate,
|
|
static size_t tor_zlib_state_size_precalc(int inflate,
|
|
int windowbits, int memlevel);
|
|
int windowbits, int memlevel);
|
|
|
|
|
|
|
|
|
|
static size_t total_zlib_allocation = 0;
|
|
static size_t total_zlib_allocation = 0;
|
|
|
|
|
|
-
|
|
|
|
- * set to -1 if we haven't checked yet. */
|
|
|
|
-static int gzip_is_supported = -1;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- * use zlib. */
|
|
|
|
-int
|
|
|
|
-is_gzip_supported(void)
|
|
|
|
-{
|
|
|
|
- if (gzip_is_supported >= 0)
|
|
|
|
- return gzip_is_supported;
|
|
|
|
-
|
|
|
|
- if (!strcmpstart(ZLIB_VERSION, "0.") ||
|
|
|
|
- !strcmpstart(ZLIB_VERSION, "1.0") ||
|
|
|
|
- !strcmpstart(ZLIB_VERSION, "1.1"))
|
|
|
|
- gzip_is_supported = 0;
|
|
|
|
- else
|
|
|
|
- gzip_is_supported = 1;
|
|
|
|
-
|
|
|
|
- return gzip_is_supported;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
|
|
|
|
* version of zlib. */
|
|
* version of zlib. */
|
|
const char *
|
|
const char *
|
|
@@ -165,12 +147,6 @@ tor_gzip_compress(char **out, size_t *out_len,
|
|
|
|
|
|
*out = NULL;
|
|
*out = NULL;
|
|
|
|
|
|
- if (method == GZIP_METHOD && !is_gzip_supported()) {
|
|
|
|
-
|
|
|
|
- log_warn(LD_BUG, "Gzip not supported with zlib %s", ZLIB_VERSION);
|
|
|
|
- goto err;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
stream = tor_malloc_zero(sizeof(struct z_stream_s));
|
|
stream = tor_malloc_zero(sizeof(struct z_stream_s));
|
|
stream->zalloc = Z_NULL;
|
|
stream->zalloc = Z_NULL;
|
|
stream->zfree = Z_NULL;
|
|
stream->zfree = Z_NULL;
|
|
@@ -291,12 +267,6 @@ tor_gzip_uncompress(char **out, size_t *out_len,
|
|
tor_assert(in);
|
|
tor_assert(in);
|
|
tor_assert(in_len < UINT_MAX);
|
|
tor_assert(in_len < UINT_MAX);
|
|
|
|
|
|
- if (method == GZIP_METHOD && !is_gzip_supported()) {
|
|
|
|
-
|
|
|
|
- log_warn(LD_BUG, "Gzip not supported with zlib %s", ZLIB_VERSION);
|
|
|
|
- return -1;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
*out = NULL;
|
|
*out = NULL;
|
|
|
|
|
|
stream = tor_malloc_zero(sizeof(struct z_stream_s));
|
|
stream = tor_malloc_zero(sizeof(struct z_stream_s));
|
|
@@ -451,12 +421,6 @@ tor_zlib_new(int compress, compress_method_t method,
|
|
tor_zlib_state_t *out;
|
|
tor_zlib_state_t *out;
|
|
int bits, memlevel;
|
|
int bits, memlevel;
|
|
|
|
|
|
- if (method == GZIP_METHOD && !is_gzip_supported()) {
|
|
|
|
-
|
|
|
|
- log_warn(LD_BUG, "Gzip not supported with zlib %s", ZLIB_VERSION);
|
|
|
|
- return NULL;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
if (! compress) {
|
|
if (! compress) {
|
|
|
|
|
|
* max number of window bits */
|
|
* max number of window bits */
|