--- old/src/share/bin/parse_manifest.c 2015-10-13 20:02:33.758332400 +0400 +++ new/src/share/bin/parse_manifest.c 2015-10-13 20:02:33.560210000 +0400 @@ -91,7 +91,7 @@ } zs.next_out = (Byte*)out; zs.avail_out = (uInt)entry->isize; - if (inflate(&zs, Z_PARTIAL_FLUSH) < 0) { + if (inflate(&zs, Z_FINISH) != Z_STREAM_END) { free(in); free(out); return (NULL); --- old/src/share/native/com/sun/java/util/jar/pack/zip.cpp 2015-10-13 20:02:35.145189200 +0400 +++ new/src/share/native/com/sun/java/util/jar/pack/zip.cpp 2015-10-13 20:02:34.947066800 +0400 @@ -451,8 +451,11 @@ zs.avail_in = (int) read_gzin_fn(u, inbuf, 1, inbuflen); zs.next_in = (uchar*) inbuf; } - int error = inflate(&zs, Z_NO_FLUSH); - if (error != Z_OK && error != Z_STREAM_END) { + // When flush is set to Z_FINISH, inflate() cannot return Z_OK. Instead it + // will return Z_BUF_ERROR if it has not reached the end of the stream. + // So, the only normal return codes are Z_BUF_ERROR and Z_STREAM_END. + int error = inflate(&zs, Z_FINISH); + if (error != Z_BUF_ERROR && error != Z_STREAM_END) { u->abort("error inflating input"); break; } --- old/src/share/native/java/util/zip/Inflater.c 2015-10-13 20:02:36.482515400 +0400 +++ new/src/share/native/java/util/zip/Inflater.c 2015-10-13 20:02:36.284393000 +0400 @@ -142,7 +142,7 @@ strm->next_out = (Bytef *) (out_buf + off); strm->avail_in = this_len; strm->avail_out = len; - ret = inflate(strm, Z_PARTIAL_FLUSH); + ret = inflate(strm, Z_FINISH); (*env)->ReleasePrimitiveArrayCritical(env, b, out_buf, 0); (*env)->ReleasePrimitiveArrayCritical(env, this_buf, in_buf, 0); @@ -150,7 +150,7 @@ case Z_STREAM_END: (*env)->SetBooleanField(env, this, finishedID, JNI_TRUE); /* fall through */ - case Z_OK: + case Z_BUF_ERROR: this_off += this_len - strm->avail_in; (*env)->SetIntField(env, this, offID, this_off); (*env)->SetIntField(env, this, lenID, strm->avail_in); @@ -162,8 +162,6 @@ (*env)->SetIntField(env, this, offID, this_off); (*env)->SetIntField(env, this, lenID, strm->avail_in); return 0; - case Z_BUF_ERROR: - return 0; case Z_DATA_ERROR: ThrowDataFormatException(env, strm->msg); return 0; --- old/src/share/native/java/util/zip/zip_util.c 2015-10-13 20:02:37.879277200 +0400 +++ new/src/share/native/java/util/zip/zip_util.c 2015-10-13 20:02:37.679504000 +0400 @@ -1374,9 +1374,7 @@ strm.next_in = (Bytef *)tmp; strm.avail_in = n; do { - switch (inflate(&strm, Z_PARTIAL_FLUSH)) { - case Z_OK: - break; + switch (inflate(&strm, Z_FINISH)) { case Z_STREAM_END: if (count != 0 || strm.total_out != entry->size) { *msg = "inflateFully: Unexpected end of stream";