Fix zlib CVE-2016-9842.
[rsync.git] / zlib / inflate.c
index a7555738734b89524a01fc1cc9fe14bfaf6dae28..e43abd9e02fadb4c63cbf37220f25edc2c156d18 100644 (file)
@@ -885,9 +885,10 @@ int flush;
             INITBITS();
             state->mode = COPY_;
             if (flush == Z_TREES) goto inf_leave;
+           /* FALLTHROUGH */
         case COPY_:
             state->mode = COPY;
-           /* FALL THROUGH */
+           /* FALLTHROUGH */
         case COPY:
             copy = state->length;
             if (copy) {
@@ -1525,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));
 }