jdk/src/java.base/share/native/libzip/zip_util.c
changeset 27565 729f9700483a
parent 27186 c1b8debdfcc2
child 29389 348a32f79d79
equal deleted inserted replaced
27564:eaaa79b68cd5 27565:729f9700483a
  1409             default:
  1409             default:
  1410                 break;
  1410                 break;
  1411             }
  1411             }
  1412         } while (strm.avail_in > 0);
  1412         } while (strm.avail_in > 0);
  1413     }
  1413     }
       
  1414 
  1414     inflateEnd(&strm);
  1415     inflateEnd(&strm);
  1415     return JNI_TRUE;
  1416     return JNI_TRUE;
  1416 }
  1417 }
  1417 
  1418 
  1418 /*
  1419 /*
  1480 
  1481 
  1481     ZIP_FreeEntry(zip, entry);
  1482     ZIP_FreeEntry(zip, entry);
  1482 
  1483 
  1483     return JNI_TRUE;
  1484     return JNI_TRUE;
  1484 }
  1485 }
       
  1486 
       
  1487 jboolean JNICALL
       
  1488 ZIP_InflateFully(void *inBuf, jlong inLen, void *outBuf, jlong outLen, char **pmsg)
       
  1489 {
       
  1490     z_stream strm;
       
  1491     int i = 0;
       
  1492     memset(&strm, 0, sizeof(z_stream));
       
  1493 
       
  1494     *pmsg = 0; /* Reset error message */
       
  1495 
       
  1496     if (inflateInit2(&strm, MAX_WBITS) != Z_OK) {
       
  1497         *pmsg = strm.msg;
       
  1498         return JNI_FALSE;
       
  1499     }
       
  1500 
       
  1501     strm.next_out = (Bytef *) outBuf;
       
  1502     strm.avail_out = (uInt)outLen;
       
  1503     strm.next_in = (Bytef *) inBuf;
       
  1504     strm.avail_in = (uInt)inLen;
       
  1505 
       
  1506     do {
       
  1507         switch (inflate(&strm, Z_PARTIAL_FLUSH)) {
       
  1508             case Z_OK:
       
  1509                 break;
       
  1510             case Z_STREAM_END:
       
  1511                 if (strm.total_out != outLen) {
       
  1512                     *pmsg = "INFLATER_inflateFully: Unexpected end of stream";
       
  1513                     inflateEnd(&strm);
       
  1514                     return JNI_FALSE;
       
  1515                 }
       
  1516                 break;
       
  1517             case Z_DATA_ERROR:
       
  1518                 *pmsg = "INFLATER_inflateFully: Compressed data corrupted";
       
  1519                 inflateEnd(&strm);
       
  1520                 return JNI_FALSE;
       
  1521             case Z_MEM_ERROR:
       
  1522                 *pmsg = "INFLATER_inflateFully: out of memory";
       
  1523                 inflateEnd(&strm);
       
  1524                 return JNI_FALSE;
       
  1525             default:
       
  1526                 *pmsg = "INFLATER_inflateFully: internal error";
       
  1527                 inflateEnd(&strm);
       
  1528                 return JNI_FALSE;
       
  1529         }
       
  1530     } while (strm.avail_in > 0);
       
  1531 
       
  1532     inflateEnd(&strm);
       
  1533     return JNI_TRUE;
       
  1534 }