Skip to content

Commit

Permalink
Fix potential missed stream close when decrypting streams
Browse files Browse the repository at this point in the history
  • Loading branch information
neuhalje committed Jan 18, 2020
1 parent 7485989 commit 012c3f9
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,16 @@ private InputStream nextDecryptedStream(PGPObjectFactory factory,

// decrypt the data

final InputStream plainText = pbe
try(
InputStream plainText = pbe
.getDataStream(new BcPublicKeyDataDecryptorFactory(
privateKey)); // NOPMD: AvoidInstantiatingObjectsInLoops
final PGPObjectFactory nextFactory = new PGPObjectFactory(plainText,
new BcKeyFingerprintCalculator());// NOPMD: AvoidInstantiatingObjectsInLoops
return nextDecryptedStream(nextFactory, state); // NOPMD: OnlyOneReturn
privateKey)) // NOPMD: AvoidInstantiatingObjectsInLoops
)
{
final PGPObjectFactory nextFactory = new PGPObjectFactory(plainText,
new BcKeyFingerprintCalculator());// NOPMD: AvoidInstantiatingObjectsInLoops
return nextDecryptedStream(nextFactory, state); // NOPMD: OnlyOneReturn
}
} else if (pgpObj instanceof PGPCompressedData) {
LOGGER.trace("Found instance of PGPCompressedData");
final PGPObjectFactory nextFactory = new PGPObjectFactory(
Expand Down

0 comments on commit 012c3f9

Please sign in to comment.