mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8242882: opening jar file with large manifest might throw NegativeArraySizeException
Reviewed-by: bchristi, lancea
This commit is contained in:
parent
f86037207c
commit
782d45bdec
2 changed files with 85 additions and 1 deletions
|
@ -152,6 +152,8 @@ public class JarFile extends ZipFile {
|
|||
private static final boolean MULTI_RELEASE_ENABLED;
|
||||
private static final boolean MULTI_RELEASE_FORCED;
|
||||
private static final ThreadLocal<Boolean> isInitializing = new ThreadLocal<>();
|
||||
// The maximum size of array to allocate. Some VMs reserve some header words in an array.
|
||||
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
|
||||
|
||||
private SoftReference<Manifest> manRef;
|
||||
private JarEntry manEntry;
|
||||
|
@ -788,7 +790,11 @@ public class JarFile extends ZipFile {
|
|||
*/
|
||||
private byte[] getBytes(ZipEntry ze) throws IOException {
|
||||
try (InputStream is = super.getInputStream(ze)) {
|
||||
int len = (int)ze.getSize();
|
||||
long uncompressedSize = ze.getSize();
|
||||
if (uncompressedSize > MAX_ARRAY_SIZE) {
|
||||
throw new OutOfMemoryError("Required array size too large");
|
||||
}
|
||||
int len = (int)uncompressedSize;
|
||||
int bytesRead;
|
||||
byte[] b;
|
||||
// trust specified entry sizes when reasonably small
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue