torgzip.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. /* Copyright (c) 2004, Roger Dingledine.
  2. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
  3. * Copyright (c) 2007-2016, The Tor Project, Inc. */
  4. /* See LICENSE for licensing information */
  5. /**
  6. * \file torgzip.c
  7. * \brief A simple in-memory gzip implementation.
  8. **/
  9. #include "orconfig.h"
  10. #include <stdlib.h>
  11. #include <stdio.h>
  12. #include <assert.h>
  13. #include <string.h>
  14. #include "torint.h"
  15. #ifdef HAVE_NETINET_IN_H
  16. #include <netinet/in.h>
  17. #endif
  18. #include "util.h"
  19. #include "torlog.h"
  20. #include "torgzip.h"
  21. /* zlib 1.2.4 and 1.2.5 do some "clever" things with macros. Instead of
  22. saying "(defined(FOO) ? FOO : 0)" they like to say "FOO-0", on the theory
  23. that nobody will care if the compile outputs a no-such-identifier warning.
  24. Sorry, but we like -Werror over here, so I guess we need to define these.
  25. I hope that zlib 1.2.6 doesn't break these too.
  26. */
  27. #ifndef _LARGEFILE64_SOURCE
  28. #define _LARGEFILE64_SOURCE 0
  29. #endif
  30. #ifndef _LFS64_LARGEFILE
  31. #define _LFS64_LARGEFILE 0
  32. #endif
  33. #ifndef _FILE_OFFSET_BITS
  34. #define _FILE_OFFSET_BITS 0
  35. #endif
  36. #ifndef off64_t
  37. #define off64_t int64_t
  38. #endif
  39. #include <zlib.h>
  40. static size_t tor_zlib_state_size_precalc(int inflate,
  41. int windowbits, int memlevel);
  42. /** Total number of bytes allocated for zlib state */
  43. static size_t total_zlib_allocation = 0;
  44. /** Set to 1 if zlib is a version that supports gzip; set to 0 if it doesn't;
  45. * set to -1 if we haven't checked yet. */
  46. static int gzip_is_supported = -1;
  47. /** Return true iff we support gzip-based compression. Otherwise, we need to
  48. * use zlib. */
  49. int
  50. is_gzip_supported(void)
  51. {
  52. if (gzip_is_supported >= 0)
  53. return gzip_is_supported;
  54. if (!strcmpstart(ZLIB_VERSION, "0.") ||
  55. !strcmpstart(ZLIB_VERSION, "1.0") ||
  56. !strcmpstart(ZLIB_VERSION, "1.1"))
  57. gzip_is_supported = 0;
  58. else
  59. gzip_is_supported = 1;
  60. return gzip_is_supported;
  61. }
  62. /** Return a string representation of the version of the currently running
  63. * version of zlib. */
  64. const char *
  65. tor_zlib_get_version_str(void)
  66. {
  67. return zlibVersion();
  68. }
  69. /** Return a string representation of the version of the version of zlib
  70. * used at compilation. */
  71. const char *
  72. tor_zlib_get_header_version_str(void)
  73. {
  74. return ZLIB_VERSION;
  75. }
  76. /** Return the 'bits' value to tell zlib to use <b>method</b>.*/
  77. static inline int
  78. method_bits(compress_method_t method, zlib_compression_level_t level)
  79. {
  80. /* Bits+16 means "use gzip" in zlib >= 1.2 */
  81. const int flag = method == GZIP_METHOD ? 16 : 0;
  82. switch (level) {
  83. default:
  84. case HIGH_COMPRESSION: return flag + 15;
  85. case MEDIUM_COMPRESSION: return flag + 13;
  86. case LOW_COMPRESSION: return flag + 11;
  87. }
  88. }
  89. static inline int
  90. get_memlevel(zlib_compression_level_t level)
  91. {
  92. switch (level) {
  93. default:
  94. case HIGH_COMPRESSION: return 8;
  95. case MEDIUM_COMPRESSION: return 7;
  96. case LOW_COMPRESSION: return 6;
  97. }
  98. }
  99. /** @{ */
  100. /* These macros define the maximum allowable compression factor. Anything of
  101. * size greater than CHECK_FOR_COMPRESSION_BOMB_AFTER is not allowed to
  102. * have an uncompression factor (uncompressed size:compressed size ratio) of
  103. * any greater than MAX_UNCOMPRESSION_FACTOR.
  104. *
  105. * Picking a value for MAX_UNCOMPRESSION_FACTOR is a trade-off: we want it to
  106. * be small to limit the attack multiplier, but we also want it to be large
  107. * enough so that no legitimate document --even ones we might invent in the
  108. * future -- ever compresses by a factor of greater than
  109. * MAX_UNCOMPRESSION_FACTOR. Within those parameters, there's a reasonably
  110. * large range of possible values. IMO, anything over 8 is probably safe; IMO
  111. * anything under 50 is probably sufficient.
  112. */
  113. #define MAX_UNCOMPRESSION_FACTOR 25
  114. #define CHECK_FOR_COMPRESSION_BOMB_AFTER (1024*64)
  115. /** @} */
  116. /** Return true if uncompressing an input of size <b>in_size</b> to an input
  117. * of size at least <b>size_out</b> looks like a compression bomb. */
  118. static int
  119. is_compression_bomb(size_t size_in, size_t size_out)
  120. {
  121. if (size_in == 0 || size_out < CHECK_FOR_COMPRESSION_BOMB_AFTER)
  122. return 0;
  123. return (size_out / size_in > MAX_UNCOMPRESSION_FACTOR);
  124. }
  125. /** Given <b>in_len</b> bytes at <b>in</b>, compress them into a newly
  126. * allocated buffer, using the method described in <b>method</b>. Store the
  127. * compressed string in *<b>out</b>, and its length in *<b>out_len</b>.
  128. * Return 0 on success, -1 on failure.
  129. */
  130. int
  131. tor_gzip_compress(char **out, size_t *out_len,
  132. const char *in, size_t in_len,
  133. compress_method_t method)
  134. {
  135. struct z_stream_s *stream = NULL;
  136. size_t out_size, old_size;
  137. off_t offset;
  138. tor_assert(out);
  139. tor_assert(out_len);
  140. tor_assert(in);
  141. tor_assert(in_len < UINT_MAX);
  142. *out = NULL;
  143. if (method == GZIP_METHOD && !is_gzip_supported()) {
  144. /* Old zlib version don't support gzip in deflateInit2 */
  145. log_warn(LD_BUG, "Gzip not supported with zlib %s", ZLIB_VERSION);
  146. goto err;
  147. }
  148. stream = tor_malloc_zero(sizeof(struct z_stream_s));
  149. stream->zalloc = Z_NULL;
  150. stream->zfree = Z_NULL;
  151. stream->opaque = NULL;
  152. stream->next_in = (unsigned char*) in;
  153. stream->avail_in = (unsigned int)in_len;
  154. if (deflateInit2(stream, Z_BEST_COMPRESSION, Z_DEFLATED,
  155. method_bits(method, HIGH_COMPRESSION),
  156. get_memlevel(HIGH_COMPRESSION),
  157. Z_DEFAULT_STRATEGY) != Z_OK) {
  158. log_warn(LD_GENERAL, "Error from deflateInit2: %s",
  159. stream->msg?stream->msg:"<no message>");
  160. goto err;
  161. }
  162. /* Guess 50% compression. */
  163. out_size = in_len / 2;
  164. if (out_size < 1024) out_size = 1024;
  165. *out = tor_malloc(out_size);
  166. stream->next_out = (unsigned char*)*out;
  167. stream->avail_out = (unsigned int)out_size;
  168. while (1) {
  169. switch (deflate(stream, Z_FINISH))
  170. {
  171. case Z_STREAM_END:
  172. goto done;
  173. case Z_OK:
  174. /* In case zlib doesn't work as I think .... */
  175. if (stream->avail_out >= stream->avail_in+16)
  176. break;
  177. case Z_BUF_ERROR:
  178. offset = stream->next_out - ((unsigned char*)*out);
  179. old_size = out_size;
  180. out_size *= 2;
  181. if (out_size < old_size) {
  182. log_warn(LD_GENERAL, "Size overflow in compression.");
  183. goto err;
  184. }
  185. *out = tor_realloc(*out, out_size);
  186. stream->next_out = (unsigned char*)(*out + offset);
  187. if (out_size - offset > UINT_MAX) {
  188. log_warn(LD_BUG, "Ran over unsigned int limit of zlib while "
  189. "uncompressing.");
  190. goto err;
  191. }
  192. stream->avail_out = (unsigned int)(out_size - offset);
  193. break;
  194. default:
  195. log_warn(LD_GENERAL, "Gzip compression didn't finish: %s",
  196. stream->msg ? stream->msg : "<no message>");
  197. goto err;
  198. }
  199. }
  200. done:
  201. *out_len = stream->total_out;
  202. #ifdef OPENBSD
  203. /* "Hey Rocky! Watch me change an unsigned field to a signed field in a
  204. * third-party API!"
  205. * "Oh, that trick will just make people do unsafe casts to the unsigned
  206. * type in their cross-platform code!"
  207. * "Don't be foolish. I'm _sure_ they'll have the good sense to make sure
  208. * the newly unsigned field isn't negative." */
  209. tor_assert(stream->total_out >= 0);
  210. #endif
  211. if (((size_t)stream->total_out) > out_size + 4097) {
  212. /* If we're wasting more than 4k, don't. */
  213. *out = tor_realloc(*out, stream->total_out + 1);
  214. }
  215. if (deflateEnd(stream)!=Z_OK) {
  216. log_warn(LD_BUG, "Error freeing gzip structures");
  217. goto err;
  218. }
  219. tor_free(stream);
  220. if (is_compression_bomb(*out_len, in_len)) {
  221. log_warn(LD_BUG, "We compressed something and got an insanely high "
  222. "compression factor; other Tors would think this was a zlib bomb.");
  223. goto err;
  224. }
  225. return 0;
  226. err:
  227. if (stream) {
  228. deflateEnd(stream);
  229. tor_free(stream);
  230. }
  231. tor_free(*out);
  232. return -1;
  233. }
  234. /** Given zero or more zlib-compressed or gzip-compressed strings of
  235. * total length
  236. * <b>in_len</b> bytes at <b>in</b>, uncompress them into a newly allocated
  237. * buffer, using the method described in <b>method</b>. Store the uncompressed
  238. * string in *<b>out</b>, and its length in *<b>out_len</b>. Return 0 on
  239. * success, -1 on failure.
  240. *
  241. * If <b>complete_only</b> is true, we consider a truncated input as a
  242. * failure; otherwise we decompress as much as we can. Warn about truncated
  243. * or corrupt inputs at <b>protocol_warn_level</b>.
  244. */
  245. int
  246. tor_gzip_uncompress(char **out, size_t *out_len,
  247. const char *in, size_t in_len,
  248. compress_method_t method,
  249. int complete_only,
  250. int protocol_warn_level)
  251. {
  252. struct z_stream_s *stream = NULL;
  253. size_t out_size, old_size;
  254. off_t offset;
  255. int r;
  256. tor_assert(out);
  257. tor_assert(out_len);
  258. tor_assert(in);
  259. tor_assert(in_len < UINT_MAX);
  260. if (method == GZIP_METHOD && !is_gzip_supported()) {
  261. /* Old zlib version don't support gzip in inflateInit2 */
  262. log_warn(LD_BUG, "Gzip not supported with zlib %s", ZLIB_VERSION);
  263. return -1;
  264. }
  265. *out = NULL;
  266. stream = tor_malloc_zero(sizeof(struct z_stream_s));
  267. stream->zalloc = Z_NULL;
  268. stream->zfree = Z_NULL;
  269. stream->opaque = NULL;
  270. stream->next_in = (unsigned char*) in;
  271. stream->avail_in = (unsigned int)in_len;
  272. if (inflateInit2(stream,
  273. method_bits(method, HIGH_COMPRESSION)) != Z_OK) {
  274. log_warn(LD_GENERAL, "Error from inflateInit2: %s",
  275. stream->msg?stream->msg:"<no message>");
  276. goto err;
  277. }
  278. out_size = in_len * 2; /* guess 50% compression. */
  279. if (out_size < 1024) out_size = 1024;
  280. if (out_size >= SIZE_T_CEILING || out_size > UINT_MAX)
  281. goto err;
  282. *out = tor_malloc(out_size);
  283. stream->next_out = (unsigned char*)*out;
  284. stream->avail_out = (unsigned int)out_size;
  285. while (1) {
  286. switch (inflate(stream, complete_only ? Z_FINISH : Z_SYNC_FLUSH))
  287. {
  288. case Z_STREAM_END:
  289. if (stream->avail_in == 0)
  290. goto done;
  291. /* There may be more compressed data here. */
  292. if ((r = inflateEnd(stream)) != Z_OK) {
  293. log_warn(LD_BUG, "Error freeing gzip structures");
  294. goto err;
  295. }
  296. if (inflateInit2(stream,
  297. method_bits(method,HIGH_COMPRESSION)) != Z_OK) {
  298. log_warn(LD_GENERAL, "Error from second inflateInit2: %s",
  299. stream->msg?stream->msg:"<no message>");
  300. goto err;
  301. }
  302. break;
  303. case Z_OK:
  304. if (!complete_only && stream->avail_in == 0)
  305. goto done;
  306. /* In case zlib doesn't work as I think.... */
  307. if (stream->avail_out >= stream->avail_in+16)
  308. break;
  309. case Z_BUF_ERROR:
  310. if (stream->avail_out > 0) {
  311. log_fn(protocol_warn_level, LD_PROTOCOL,
  312. "possible truncated or corrupt zlib data");
  313. goto err;
  314. }
  315. offset = stream->next_out - (unsigned char*)*out;
  316. old_size = out_size;
  317. out_size *= 2;
  318. if (out_size < old_size) {
  319. log_warn(LD_GENERAL, "Size overflow in uncompression.");
  320. goto err;
  321. }
  322. if (is_compression_bomb(in_len, out_size)) {
  323. log_warn(LD_GENERAL, "Input looks like a possible zlib bomb; "
  324. "not proceeding.");
  325. goto err;
  326. }
  327. if (out_size >= SIZE_T_CEILING) {
  328. log_warn(LD_BUG, "Hit SIZE_T_CEILING limit while uncompressing.");
  329. goto err;
  330. }
  331. *out = tor_realloc(*out, out_size);
  332. stream->next_out = (unsigned char*)(*out + offset);
  333. if (out_size - offset > UINT_MAX) {
  334. log_warn(LD_BUG, "Ran over unsigned int limit of zlib while "
  335. "uncompressing.");
  336. goto err;
  337. }
  338. stream->avail_out = (unsigned int)(out_size - offset);
  339. break;
  340. default:
  341. log_warn(LD_GENERAL, "Gzip decompression returned an error: %s",
  342. stream->msg ? stream->msg : "<no message>");
  343. goto err;
  344. }
  345. }
  346. done:
  347. *out_len = stream->next_out - (unsigned char*)*out;
  348. r = inflateEnd(stream);
  349. tor_free(stream);
  350. if (r != Z_OK) {
  351. log_warn(LD_BUG, "Error freeing gzip structures");
  352. goto err;
  353. }
  354. /* NUL-terminate output. */
  355. if (out_size == *out_len)
  356. *out = tor_realloc(*out, out_size + 1);
  357. (*out)[*out_len] = '\0';
  358. return 0;
  359. err:
  360. if (stream) {
  361. inflateEnd(stream);
  362. tor_free(stream);
  363. }
  364. if (*out) {
  365. tor_free(*out);
  366. }
  367. return -1;
  368. }
  369. /** Try to tell whether the <b>in_len</b>-byte string in <b>in</b> is likely
  370. * to be compressed or not. If it is, return the likeliest compression method.
  371. * Otherwise, return UNKNOWN_METHOD.
  372. */
  373. compress_method_t
  374. detect_compression_method(const char *in, size_t in_len)
  375. {
  376. if (in_len > 2 && fast_memeq(in, "\x1f\x8b", 2)) {
  377. return GZIP_METHOD;
  378. } else if (in_len > 2 && (in[0] & 0x0f) == 8 &&
  379. (ntohs(get_uint16(in)) % 31) == 0) {
  380. return ZLIB_METHOD;
  381. } else {
  382. return UNKNOWN_METHOD;
  383. }
  384. }
  385. /** Internal state for an incremental zlib compression/decompression. The
  386. * body of this struct is not exposed. */
  387. struct tor_zlib_state_t {
  388. struct z_stream_s stream; /**< The zlib stream */
  389. int compress; /**< True if we are compressing; false if we are inflating */
  390. /** Number of bytes read so far. Used to detect zlib bombs. */
  391. size_t input_so_far;
  392. /** Number of bytes written so far. Used to detect zlib bombs. */
  393. size_t output_so_far;
  394. /** Approximate number of bytes allocated for this object. */
  395. size_t allocation;
  396. };
  397. /** Construct and return a tor_zlib_state_t object using <b>method</b>. If
  398. * <b>compress</b>, it's for compression; otherwise it's for
  399. * decompression. */
  400. tor_zlib_state_t *
  401. tor_zlib_new(int compress, compress_method_t method,
  402. zlib_compression_level_t compression_level)
  403. {
  404. tor_zlib_state_t *out;
  405. int bits, memlevel;
  406. if (method == GZIP_METHOD && !is_gzip_supported()) {
  407. /* Old zlib version don't support gzip in inflateInit2 */
  408. log_warn(LD_BUG, "Gzip not supported with zlib %s", ZLIB_VERSION);
  409. return NULL;
  410. }
  411. if (! compress) {
  412. /* use this setting for decompression, since we might have the
  413. * max number of window bits */
  414. compression_level = HIGH_COMPRESSION;
  415. }
  416. out = tor_malloc_zero(sizeof(tor_zlib_state_t));
  417. out->stream.zalloc = Z_NULL;
  418. out->stream.zfree = Z_NULL;
  419. out->stream.opaque = NULL;
  420. out->compress = compress;
  421. bits = method_bits(method, compression_level);
  422. memlevel = get_memlevel(compression_level);
  423. if (compress) {
  424. if (deflateInit2(&out->stream, Z_BEST_COMPRESSION, Z_DEFLATED,
  425. bits, memlevel,
  426. Z_DEFAULT_STRATEGY) != Z_OK)
  427. goto err;
  428. } else {
  429. if (inflateInit2(&out->stream, bits) != Z_OK)
  430. goto err;
  431. }
  432. out->allocation = tor_zlib_state_size_precalc(!compress, bits, memlevel);
  433. total_zlib_allocation += out->allocation;
  434. return out;
  435. err:
  436. tor_free(out);
  437. return NULL;
  438. }
  439. /** Compress/decompress some bytes using <b>state</b>. Read up to
  440. * *<b>in_len</b> bytes from *<b>in</b>, and write up to *<b>out_len</b> bytes
  441. * to *<b>out</b>, adjusting the values as we go. If <b>finish</b> is true,
  442. * we've reached the end of the input.
  443. *
  444. * Return TOR_ZLIB_DONE if we've finished the entire compression/decompression.
  445. * Return TOR_ZLIB_OK if we're processed everything from the input.
  446. * Return TOR_ZLIB_BUF_FULL if we're out of space on <b>out</b>.
  447. * Return TOR_ZLIB_ERR if the stream is corrupt.
  448. */
  449. tor_zlib_output_t
  450. tor_zlib_process(tor_zlib_state_t *state,
  451. char **out, size_t *out_len,
  452. const char **in, size_t *in_len,
  453. int finish)
  454. {
  455. int err;
  456. tor_assert(*in_len <= UINT_MAX);
  457. tor_assert(*out_len <= UINT_MAX);
  458. state->stream.next_in = (unsigned char*) *in;
  459. state->stream.avail_in = (unsigned int)*in_len;
  460. state->stream.next_out = (unsigned char*) *out;
  461. state->stream.avail_out = (unsigned int)*out_len;
  462. if (state->compress) {
  463. err = deflate(&state->stream, finish ? Z_FINISH : Z_NO_FLUSH);
  464. } else {
  465. err = inflate(&state->stream, finish ? Z_FINISH : Z_SYNC_FLUSH);
  466. }
  467. state->input_so_far += state->stream.next_in - ((unsigned char*)*in);
  468. state->output_so_far += state->stream.next_out - ((unsigned char*)*out);
  469. *out = (char*) state->stream.next_out;
  470. *out_len = state->stream.avail_out;
  471. *in = (const char *) state->stream.next_in;
  472. *in_len = state->stream.avail_in;
  473. if (! state->compress &&
  474. is_compression_bomb(state->input_so_far, state->output_so_far)) {
  475. log_warn(LD_DIR, "Possible zlib bomb; abandoning stream.");
  476. return TOR_ZLIB_ERR;
  477. }
  478. switch (err)
  479. {
  480. case Z_STREAM_END:
  481. return TOR_ZLIB_DONE;
  482. case Z_BUF_ERROR:
  483. if (state->stream.avail_in == 0 && !finish)
  484. return TOR_ZLIB_OK;
  485. return TOR_ZLIB_BUF_FULL;
  486. case Z_OK:
  487. if (state->stream.avail_out == 0 || finish)
  488. return TOR_ZLIB_BUF_FULL;
  489. return TOR_ZLIB_OK;
  490. default:
  491. log_warn(LD_GENERAL, "Gzip returned an error: %s",
  492. state->stream.msg ? state->stream.msg : "<no message>");
  493. return TOR_ZLIB_ERR;
  494. }
  495. }
  496. /** Deallocate <b>state</b>. */
  497. void
  498. tor_zlib_free(tor_zlib_state_t *state)
  499. {
  500. if (!state)
  501. return;
  502. total_zlib_allocation -= state->allocation;
  503. if (state->compress)
  504. deflateEnd(&state->stream);
  505. else
  506. inflateEnd(&state->stream);
  507. tor_free(state);
  508. }
  509. /** Return an approximate number of bytes used in RAM to hold a state with
  510. * window bits <b>windowBits</b> and compression level 'memlevel' */
  511. static size_t
  512. tor_zlib_state_size_precalc(int inflate, int windowbits, int memlevel)
  513. {
  514. windowbits &= 15;
  515. #define A_FEW_KILOBYTES 2048
  516. if (inflate) {
  517. /* From zconf.h:
  518. "The memory requirements for inflate are (in bytes) 1 << windowBits
  519. that is, 32K for windowBits=15 (default value) plus a few kilobytes
  520. for small objects."
  521. */
  522. return sizeof(tor_zlib_state_t) + sizeof(struct z_stream_s) +
  523. (1 << 15) + A_FEW_KILOBYTES;
  524. } else {
  525. /* Also from zconf.h:
  526. "The memory requirements for deflate are (in bytes):
  527. (1 << (windowBits+2)) + (1 << (memLevel+9))
  528. ... plus a few kilobytes for small objects."
  529. */
  530. return sizeof(tor_zlib_state_t) + sizeof(struct z_stream_s) +
  531. (1 << (windowbits + 2)) + (1 << (memlevel + 9)) + A_FEW_KILOBYTES;
  532. }
  533. #undef A_FEW_KILOBYTES
  534. }
  535. /** Return the approximate number of bytes allocated for <b>state</b>. */
  536. size_t
  537. tor_zlib_state_size(const tor_zlib_state_t *state)
  538. {
  539. return state->allocation;
  540. }
  541. /** Return the approximate number of bytes allocated for all zlib states. */
  542. size_t
  543. tor_zlib_get_total_allocation(void)
  544. {
  545. return total_zlib_allocation;
  546. }