mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8206863: A closed JarVerifier.VerifierStream should throw IOException
Co-authored-by: Tobias Thierer <tobiast@google.com> Reviewed-by: rasbold
This commit is contained in:
parent
b30fe07450
commit
796a53f6e5
2 changed files with 32 additions and 2 deletions
|
@ -437,7 +437,7 @@ class JarVerifier {
|
|||
InputStream is,
|
||||
JarVerifier jv) throws IOException
|
||||
{
|
||||
this.is = is;
|
||||
this.is = Objects.requireNonNull(is);
|
||||
this.jv = jv;
|
||||
this.mev = new ManifestEntryVerifier(man);
|
||||
this.jv.beginEntry(je, mev);
|
||||
|
@ -448,6 +448,7 @@ class JarVerifier {
|
|||
|
||||
public int read() throws IOException
|
||||
{
|
||||
ensureOpen();
|
||||
if (numLeft > 0) {
|
||||
int b = is.read();
|
||||
jv.update(b, mev);
|
||||
|
@ -461,6 +462,7 @@ class JarVerifier {
|
|||
}
|
||||
|
||||
public int read(byte b[], int off, int len) throws IOException {
|
||||
ensureOpen();
|
||||
if ((numLeft > 0) && (numLeft < len)) {
|
||||
len = (int)numLeft;
|
||||
}
|
||||
|
@ -488,9 +490,15 @@ class JarVerifier {
|
|||
}
|
||||
|
||||
public int available() throws IOException {
|
||||
ensureOpen();
|
||||
return is.available();
|
||||
}
|
||||
|
||||
private void ensureOpen() throws IOException {
|
||||
if (is == null) {
|
||||
throw new IOException("stream closed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Extended JavaUtilJarAccess CodeSource API Support
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue