mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 19:14:38 +02:00
8223730: URLClassLoader.findClass() can throw IndexOutOfBoundsException
Reviewed-by: prappo, bchristi
This commit is contained in:
parent
0f56400907
commit
1d0e182e42
1 changed files with 5 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1998, 2009, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -113,9 +113,11 @@ public abstract class Resource {
|
||||||
int bytesToRead;
|
int bytesToRead;
|
||||||
if (pos >= b.length) { // Only expand when there's no room
|
if (pos >= b.length) { // Only expand when there's no room
|
||||||
bytesToRead = Math.min(len - pos, b.length + 1024);
|
bytesToRead = Math.min(len - pos, b.length + 1024);
|
||||||
if (b.length < pos + bytesToRead) {
|
if (bytesToRead < 0) {
|
||||||
b = Arrays.copyOf(b, pos + bytesToRead);
|
// Can overflow only due to large b.length
|
||||||
|
bytesToRead = len - pos;
|
||||||
}
|
}
|
||||||
|
b = Arrays.copyOf(b, pos + bytesToRead);
|
||||||
} else {
|
} else {
|
||||||
bytesToRead = b.length - pos;
|
bytesToRead = b.length - pos;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue