Skip to content

Commit

Permalink
better error checking in Extra Field parsing. closes #31
Browse files Browse the repository at this point in the history
thejoshwolfe committed Jun 4, 2016

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent fd57108 commit ba2b764
Showing 3 changed files with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -281,10 +281,12 @@ ZipFile.prototype.readEntry = function() {
entry.extraFields = [];
var i = 0;
while (i < extraFieldBuffer.length) {
if (i >= extraFieldBuffer.length - 4) return emitErrorAndAutoClose(self, new Error("unexpected end of Extra Field buffer"));
var headerId = extraFieldBuffer.readUInt16LE(i + 0);
var dataSize = extraFieldBuffer.readUInt16LE(i + 2);
var dataStart = i + 4;
var dataEnd = dataStart + dataSize;
if (dataEnd > extraFieldBuffer.length) return emitErrorAndAutoClose(self, new Error("extra field length exceeds Extra Field buffer size"));
var dataBuffer = new Buffer(dataSize);
extraFieldBuffer.copy(dataBuffer, 0, dataStart, dataEnd);
entry.extraFields.push({
Binary file not shown.
Binary file not shown.

0 comments on commit ba2b764

Please sign in to comment.