From 6d60c4d4684c2c03a43f1b8720497348cf17d357 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Wed, 16 Dec 2015 08:59:01 +0000 Subject: [PATCH] Revert "Make zlib API constness-aware" This reverts commit fb0246c6fd7cd34b820558f75eb48bba6326b768. That commit assumes that if you define Z_CONST, z_const will be defined; that is *not* the case with older versions of zlib, which don't define z_const under any circumstances. Change-Id: I6f9b7ea18922799b1aaf94dc2c63120128f2550a Reviewed-on: https://code.wireshark.org/review/12671 Reviewed-by: Guy Harris --- epan/dissectors/packet-spdy.c | 3 +-- epan/tvbuff_zlib.c | 1 - wiretap/file_wrappers.c | 9 ++++++--- wiretap/wtap.c | 4 ++++ 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/epan/dissectors/packet-spdy.c b/epan/dissectors/packet-spdy.c index 7bca0b2474..a16d4cf61d 100644 --- a/epan/dissectors/packet-spdy.c +++ b/epan/dissectors/packet-spdy.c @@ -42,7 +42,6 @@ #include "packet-ssl.h" #ifdef HAVE_LIBZ -#define ZLIB_CONST #include #endif @@ -962,7 +961,7 @@ static guint8* spdy_decompress_header_block(tvbuff_t *tvb, const guint8 *hptr = tvb_get_ptr(tvb, offset, length); guint8 *uncomp_block = (guint8 *)wmem_alloc(wmem_packet_scope(), DECOMPRESS_BUFSIZE); - decomp->next_in = hptr; + decomp->next_in = (Bytef *)hptr; decomp->avail_in = length; decomp->next_out = uncomp_block; decomp->avail_out = DECOMPRESS_BUFSIZE; diff --git a/epan/tvbuff_zlib.c b/epan/tvbuff_zlib.c index 218ff53cb2..c92a5d506d 100644 --- a/epan/tvbuff_zlib.c +++ b/epan/tvbuff_zlib.c @@ -28,7 +28,6 @@ #include #ifdef HAVE_LIBZ -#define ZLIB_CONST #include #endif diff --git a/wiretap/file_wrappers.c b/wiretap/file_wrappers.c index 07daad1d6d..5918a55f6f 100644 --- a/wiretap/file_wrappers.c +++ b/wiretap/file_wrappers.c @@ -48,7 +48,6 @@ #include #ifdef HAVE_LIBZ -#define ZLIB_CONST #include #endif /* HAVE_LIBZ */ @@ -129,7 +128,7 @@ struct wtap_reader { const char *err_info; /* additional error information string for some errors */ guint avail_in; /* number of bytes available at next_in */ - const guint8 *next_in; /* next input byte */ + unsigned char *next_in; /* next input byte */ #ifdef HAVE_LIBZ /* zlib inflate stream */ z_stream strm; /* stream structure in-place (not a pointer) */ @@ -1673,7 +1672,7 @@ gzwfile_write(GZWFILE_T state, const void *buf, guint len) n = state->size - strm->avail_in; if (n > len) n = len; - memcpy((Bytef *)strm->next_in + strm->avail_in, buf, n); + memcpy(strm->next_in + strm->avail_in, buf, n); strm->avail_in += n; state->pos += n; buf = (const char *)buf + n; @@ -1689,7 +1688,11 @@ gzwfile_write(GZWFILE_T state, const void *buf, guint len) /* directly compress user buffer to file */ strm->avail_in = len; +#if ZLIB_CONST strm->next_in = (z_const Bytef *)buf; +#else + strm->next_in = (Bytef *)buf; +#endif state->pos += len; if (gz_comp(state, Z_NO_FLUSH) == -1) return 0; diff --git a/wiretap/wtap.c b/wiretap/wtap.c index c4c35e8a74..30b66cd46f 100644 --- a/wiretap/wtap.c +++ b/wiretap/wtap.c @@ -27,6 +27,10 @@ #include #endif +#ifdef HAVE_LIBZ +#include +#endif + #include "wtap-int.h" #include "file_wrappers.h"