From e55eebc5ed578e1bf8558f68dd35297d8189810b Mon Sep 17 00:00:00 2001 From: Anthony Scarpino Date: Mon, 14 Apr 2014 21:02:31 +0000 Subject: [PATCH] 8037846: Ensure streaming of input cipher streams Reviewed-by: xuelei, valeriep --- .../share/classes/javax/crypto/CipherInputStream.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/jdk/src/java.base/share/classes/javax/crypto/CipherInputStream.java b/jdk/src/java.base/share/classes/javax/crypto/CipherInputStream.java index f9be4611d83..0930f9d6426 100644 --- a/jdk/src/java.base/share/classes/javax/crypto/CipherInputStream.java +++ b/jdk/src/java.base/share/classes/javax/crypto/CipherInputStream.java @@ -107,9 +107,10 @@ public class CipherInputStream extends FilterInputStream { done = true; try { obuffer = cipher.doFinal(); + } catch (IllegalBlockSizeException | BadPaddingException e) { + obuffer = null; + throw new IOException(e); } - catch (IllegalBlockSizeException e) {obuffer = null;} - catch (BadPaddingException e) {obuffer = null;} if (obuffer == null) return -1; else { @@ -120,7 +121,10 @@ public class CipherInputStream extends FilterInputStream { } try { obuffer = cipher.update(ibuffer, 0, readin); - } catch (IllegalStateException e) {obuffer = null;}; + } catch (IllegalStateException e) { + obuffer = null; + throw e; + } ostart = 0; if (obuffer == null) ofinish = 0; @@ -302,6 +306,7 @@ public class CipherInputStream extends FilterInputStream { } } catch (BadPaddingException | IllegalBlockSizeException ex) { + throw new IOException(ex); } ostart = 0; ofinish = 0;