From 17e26cdce572f3a0aa2c60633a5626708ee5353d Mon Sep 17 00:00:00 2001 From: alexmullins Date: Thu, 29 Oct 2015 19:14:48 -0500 Subject: [PATCH] fix slice index out of range when dealing with compressed files. --- README.txt | 2 +- reader.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.txt b/README.txt index abe9011..aa95b5d 100644 --- a/README.txt +++ b/README.txt @@ -67,5 +67,5 @@ Refer to http://www.winzip.com/aes_info.htm#winzip11 for the reasoning. 16. Storage Format (file data payload) totals CompressedSize64 bytes: a. Salt - 8, 12, or 16 bytes depending on keysize b. Password Verification Value - 2 bytes - c. Encrypted Data - UncompressedSize64 bytes + c. Encrypted Data - compressed size - satl - pwv - auth lengths d. Authentication code - 10 bytes diff --git a/reader.go b/reader.go index 45f4023..ff7909b 100644 --- a/reader.go +++ b/reader.go @@ -218,7 +218,7 @@ func newDecryptionReader(r io.Reader, f *File) (io.Reader, error) { salt := content[:saltLen] pwvv := content[saltLen : saltLen+2] content = content[saltLen+2:] - size := f.UncompressedSize64 + size := f.CompressedSize64 - uint64(saltLen) - 2 - 10 data := content[:size] authcode := content[size:] // generate keys