diff --git a/epan/dissectors/packet-spdy.c b/epan/dissectors/packet-spdy.c index a16d4cf61d..870f4d30b6 100644 --- a/epan/dissectors/packet-spdy.c +++ b/epan/dissectors/packet-spdy.c @@ -42,6 +42,7 @@ #include "packet-ssl.h" #ifdef HAVE_LIBZ +#define ZLIB_CONST #include #endif @@ -961,7 +962,13 @@ 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); +#ifdef z_const + decomp->next_in = (z_const Bytef *)hptr; +#else +DIAG_OFF(cast-qual) decomp->next_in = (Bytef *)hptr; +DIAG_ON(cast-qual) +#endif 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 c92a5d506d..218ff53cb2 100644 --- a/epan/tvbuff_zlib.c +++ b/epan/tvbuff_zlib.c @@ -28,6 +28,7 @@ #include #ifdef HAVE_LIBZ +#define ZLIB_CONST #include #endif diff --git a/wiretap/file_wrappers.c b/wiretap/file_wrappers.c index 5918a55f6f..0edd8945bb 100644 --- a/wiretap/file_wrappers.c +++ b/wiretap/file_wrappers.c @@ -45,9 +45,11 @@ #include #include "wtap-int.h" #include "file_wrappers.h" +#include #include #ifdef HAVE_LIBZ +#define ZLIB_CONST #include #endif /* HAVE_LIBZ */ @@ -473,7 +475,13 @@ zlib_read(FILE_T state, unsigned char *buf, unsigned int count) ret = inflate(strm, Z_NO_FLUSH); #endif state->avail_in = strm->avail_in; +#ifdef z_const +DIAG_OFF(cast-qual) + state->next_in = (unsigned char *)strm->next_in; +DIAG_ON(cast-qual) +#else state->next_in = strm->next_in; +#endif if (ret == Z_STREAM_ERROR) { state->err = WTAP_ERR_DECOMPRESS; state->err_info = strm->msg; @@ -1672,7 +1680,13 @@ gzwfile_write(GZWFILE_T state, const void *buf, guint len) n = state->size - strm->avail_in; if (n > len) n = len; +#ifdef z_const +DIAG_OFF(cast-qual) + memcpy((Bytef *)strm->next_in + strm->avail_in, buf, n); +DIAG_ON(cast-qual) +#else memcpy(strm->next_in + strm->avail_in, buf, n); +#endif strm->avail_in += n; state->pos += n; buf = (const char *)buf + n; @@ -1688,10 +1702,12 @@ gzwfile_write(GZWFILE_T state, const void *buf, guint len) /* directly compress user buffer to file */ strm->avail_in = len; -#if ZLIB_CONST +#ifdef z_const strm->next_in = (z_const Bytef *)buf; #else +DIAG_OFF(cast-qual) strm->next_in = (Bytef *)buf; +DIAG_ON(cast-qual) #endif state->pos += len; if (gz_comp(state, Z_NO_FLUSH) == -1) diff --git a/wiretap/wtap.c b/wiretap/wtap.c index 30b66cd46f..c4c35e8a74 100644 --- a/wiretap/wtap.c +++ b/wiretap/wtap.c @@ -27,10 +27,6 @@ #include #endif -#ifdef HAVE_LIBZ -#include -#endif - #include "wtap-int.h" #include "file_wrappers.h"