From e3dbf81a8e1dabc716c9a7abe08914c7bb239e22 Mon Sep 17 00:00:00 2001 From: Maschell Date: Wed, 10 Apr 2019 17:54:20 +0200 Subject: [PATCH] Add try catch arround the output write in decryptFileStreamHashed to check if the output stream was already closed. --- .../jnus/utils/cryptography/NUSDecryption.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/de/mas/wiiu/jnus/utils/cryptography/NUSDecryption.java b/src/de/mas/wiiu/jnus/utils/cryptography/NUSDecryption.java index abeef76..c917ea9 100644 --- a/src/de/mas/wiiu/jnus/utils/cryptography/NUSDecryption.java +++ b/src/de/mas/wiiu/jnus/utils/cryptography/NUSDecryption.java @@ -201,9 +201,8 @@ public class NUSDecryption extends AESDecryption { byte[] encryptedBlockBuffer = new byte[BLOCKSIZE]; ByteArrayBuffer overflow = new ByteArrayBuffer(BLOCKSIZE); - long wrote = 0; - int inBlockBuffer; + int inBlockBuffer = 0; do { inBlockBuffer = StreamUtils.getChunkFromStream(inputStream, encryptedBlockBuffer, overflow, BLOCKSIZE); @@ -222,8 +221,15 @@ public class NUSDecryption extends AESDecryption { writeSize = (int) (filesize - wrote); } - outputStream.write(output, (int) (0 + soffset), (int) writeSize); - + try { + outputStream.write(output, (int) (0 + soffset), (int) writeSize); + } catch (IOException e) { + if (e.getMessage().equals("Pipe closed")) { + break; + } + e.printStackTrace(); + throw e; + } wrote += writeSize; block++;