Skip to content

Commit 5af315c

Browse files
authored
1 parent 37c83b7 commit 5af315c

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

lib/parseExtraField.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,25 @@ module.exports = function(extraField, vars) {
66
while(!extra && extraField && extraField.length) {
77
var candidateExtra = binary.parse(extraField)
88
.word16lu('signature')
9-
.word16lu('partsize')
10-
.word64lu('uncompressedSize')
11-
.word64lu('compressedSize')
12-
.word64lu('offset')
13-
.word64lu('disknum')
14-
.vars;
15-
16-
if(candidateExtra.signature === 0x0001) {
17-
extra = candidateExtra;
9+
.word16lu('partsize');
10+
11+
if(candidateExtra.vars.signature === 0x0001) {
12+
// the fields MUST only appear if the corresponding
13+
// Local or Central directory record field is set to 0xFFFF or 0xFFFFFFFF
14+
if (vars.uncompressedSize === 0xffffffff)
15+
candidateExtra.word64lu('uncompressedSize');
16+
if (vars.compressedSize === 0xffffffff)
17+
candidateExtra.word64lu('compressedSize');
18+
if (vars.offsetToLocalFileHeader === 0xffffffff)
19+
candidateExtra.word64lu('offset');
20+
if (vars.diskNumber === 0xffff)
21+
candidateExtra.word32lu('disknum');
22+
23+
extra = candidateExtra.vars;
1824
} else {
1925
// Advance the buffer to the next part.
2026
// The total size of this part is the 4 byte header + partsize.
21-
extraField = extraField.slice(candidateExtra.partsize + 4);
27+
extraField = extraField.slice(candidateExtra.vars.partsize + 4);
2228
}
2329
}
2430

0 commit comments

Comments
 (0)