From 8eb50bce43634b9ef9ae940778ac08a959a7e8e4 Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Sat, 16 Mar 2019 09:52:30 -0700 Subject: [PATCH] Fix zlib CVE-2016-9842. --- zlib/inflate.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/zlib/inflate.c b/zlib/inflate.c index 5ed2390d..e43abd9e 100644 --- a/zlib/inflate.c +++ b/zlib/inflate.c @@ -1526,9 +1526,10 @@ z_streamp strm; { struct inflate_state FAR *state; - if (strm == Z_NULL || strm->state == Z_NULL) return -(1L << 16); + if (strm == Z_NULL || strm->state == Z_NULL) + return (long)(((unsigned long)0 - 1) << 16); state = (struct inflate_state FAR *)strm->state; - return ((long)(state->back) << 16) + + return (long)(((unsigned long)((long)state->back)) << 16) + (state->mode == COPY ? state->length : (state->mode == MATCH ? state->was - state->length : 0)); } -- 2.47.2