Skip to content

Commit 597b31a

Browse files
#485 Check for MAC even when DataDescritor exists
1 parent 942fe57 commit 597b31a

1 file changed

Lines changed: 0 additions & 12 deletions

File tree

src/main/java/net/lingala/zip4j/io/inputstream/AesCipherInputStream.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
import net.lingala.zip4j.exception.ZipException;
55
import net.lingala.zip4j.model.AESExtraDataRecord;
66
import net.lingala.zip4j.model.LocalFileHeader;
7-
import net.lingala.zip4j.model.enums.CompressionMethod;
87
import net.lingala.zip4j.util.InternalZipConstants;
9-
import net.lingala.zip4j.util.Zip4jUtil;
108

119
import java.io.IOException;
1210
import java.io.InputStream;
@@ -124,16 +122,6 @@ protected void endOfEntryReached(InputStream inputStream) throws IOException {
124122
}
125123

126124
private void verifyContent(byte[] storedMac) throws IOException {
127-
if (getLocalFileHeader().isDataDescriptorExists()
128-
&& CompressionMethod.DEFLATE.equals(Zip4jUtil.getCompressionMethod(getLocalFileHeader()))) {
129-
// Skip content verification in case of Deflate compression and if data descriptor exists.
130-
// In this case, we do not know the exact size of compressed data before hand and it is possible that we read
131-
// and pass more than required data into inflater, thereby corrupting the aes mac bytes.
132-
// See usage of PushBackInputStream in the project for how this push back of data is done
133-
// Unfortunately, in this case we cannot perform a content verification and have to skip
134-
return;
135-
}
136-
137125
byte[] calculatedMac = getDecrypter().getCalculatedAuthenticationBytes();
138126
byte[] first10BytesOfCalculatedMac = new byte[AES_AUTH_LENGTH];
139127
System.arraycopy(calculatedMac, 0, first10BytesOfCalculatedMac, 0, InternalZipConstants.AES_AUTH_LENGTH);

0 commit comments

Comments
 (0)