Fix zlib CVE-2016-9842.
authorWayne Davison <wayned@samba.org>
Sat, 16 Mar 2019 16:52:30 +0000 (09:52 -0700)
committerWayne Davison <wayned@samba.org>
Sat, 16 Mar 2019 16:56:11 +0000 (09:56 -0700)
zlib/inflate.c

index 5ed2390..e43abd9 100644 (file)
@@ -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));
 }