Skip to content

Commit

Permalink
[CID-152201] - Fix resource leak in remoting.jnlp.Main (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-nenashev authored Aug 26, 2016
1 parent 98107a2 commit 8fbc76c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/main/java/hudson/remoting/jnlp/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,18 @@ public Engine createEngine() {
if (file.isFile()
&& (length = file.length()) < 65536
&& length > "-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----".length()) {
FileInputStream fis = null;
try {
// we do basic size validation, if there are x509 certificates that have a PEM encoding
// larger
// than 64kb we can revisit the upper bound.
cert = new byte[(int) length];
fis = new FileInputStream(file);
int read = fis.read(cert);
FileInputStream fis = new FileInputStream(file);
final int read;
try {
read = fis.read(cert);
} finally {
fis.close();
}
if (cert.length != read) {
LOGGER.log(Level.WARNING, "Only read {0} bytes from {1}, expected to read {2}",
new Object[]{read, file, cert.length});
Expand Down

0 comments on commit 8fbc76c

Please sign in to comment.