Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reading zip files containing zero-byte encrypted files #36

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ ZipFile.prototype.readEntry = function() {
// 46 - File name
var isUtf8 = entry.generalPurposeBitFlag & 0x800
entry.fileName = bufferToString(buffer, 0, entry.fileNameLength, isUtf8);
var isEncrypted = entry.generalPurposeBitFlag & 0x001;

// 46+n - Extra field
var fileCommentStart = entry.fileNameLength + entry.extraFieldLength;
Expand Down Expand Up @@ -375,7 +376,7 @@ ZipFile.prototype.readEntry = function() {
}

// validate file size
if (entry.compressionMethod === 0) {
if (entry.compressionMethod === 0 && !isEncrypted) {
if (entry.compressedSize !== entry.uncompressedSize) {
var msg = "compressed/uncompressed size mismatch for stored file: " + entry.compressedSize + " != " + entry.uncompressedSize;
return emitErrorAndAutoClose(self, new Error(msg));
Expand Down
Binary file added test/success/onebyte-encrypted.zip
Binary file not shown.
1 change: 1 addition & 0 deletions test/success/onebyte-encrypted/onebyte.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
+n�`'s�Bd�