--- old/src/java.base/share/native/libzip/zip_util.c 2014-11-20 16:03:24.449548197 +0000 +++ new/src/java.base/share/native/libzip/zip_util.c 2014-11-20 16:03:24.290537433 +0000 @@ -1411,6 +1411,7 @@ } } while (strm.avail_in > 0); } + inflateEnd(&strm); return JNI_TRUE; } @@ -1482,3 +1483,52 @@ return JNI_TRUE; } + +jboolean JNICALL +ZIP_InflateFully(void *inBuf, jlong inLen, void *outBuf, jlong outLen, char **pmsg) +{ + z_stream strm; + int i = 0; + memset(&strm, 0, sizeof(z_stream)); + + *pmsg = 0; /* Reset error message */ + + if (inflateInit2(&strm, MAX_WBITS) != Z_OK) { + *pmsg = strm.msg; + return JNI_FALSE; + } + + strm.next_out = (Bytef *) outBuf; + strm.avail_out = (uInt)outLen; + strm.next_in = (Bytef *) inBuf; + strm.avail_in = (uInt)inLen; + + do { + switch (inflate(&strm, Z_PARTIAL_FLUSH)) { + case Z_OK: + break; + case Z_STREAM_END: + if (strm.total_out != outLen) { + *pmsg = "INFLATER_inflateFully: Unexpected end of stream"; + inflateEnd(&strm); + return JNI_FALSE; + } + break; + case Z_DATA_ERROR: + *pmsg = "INFLATER_inflateFully: Compressed data corrupted"; + inflateEnd(&strm); + return JNI_FALSE; + case Z_MEM_ERROR: + *pmsg = "INFLATER_inflateFully: out of memory"; + inflateEnd(&strm); + return JNI_FALSE; + default: + *pmsg = "INFLATER_inflateFully: internal error"; + inflateEnd(&strm); + return JNI_FALSE; + } + } while (strm.avail_in > 0); + + inflateEnd(&strm); + return JNI_TRUE; +}