From 3e9f4843f858b1d69941ee012618948603f8ab44 Mon Sep 17 00:00:00 2001 From: C-3PO Date: Thu, 5 Jul 2018 02:50:47 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20compressed=20size=20calcul?= =?UTF-8?q?ation,=20do=20not=20change=20original=20decryption=20keys?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ssn/extractFileStream.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ssn/extractFileStream.ts b/src/ssn/extractFileStream.ts index ca7899d..8b6689b 100644 --- a/src/ssn/extractFileStream.ts +++ b/src/ssn/extractFileStream.ts @@ -31,13 +31,14 @@ export default function extractFileStream(file: ISsnFileEntry, inputStream: stre let curStream = inputStream; - //set max length - const maxLength = streamSetMaxLength(curStream, 12 + file.compressedSize); + const storedSize = (file.decryptionKeys !== undefined) ? (12 + file.compressedSize) : file.compressedSize; + //set max length (including random 12 byte encryption header) + const maxLength = streamSetMaxLength(curStream, storedSize); curStream = maxLength; //pipe into decryption if file is encrypted if (file.decryptionKeys !== undefined) { - const decryptTransform = decryptStream(curStream, file.decryptionKeys); + const decryptTransform = decryptStream(curStream, [...file.decryptionKeys] as [number, number, number]); curStream = decryptTransform; }