Skip to content

Commit

Permalink
Fixed the parsing of invalid ZIP64 extended information extra fields
Browse files Browse the repository at this point in the history
  • Loading branch information
ebourg committed Oct 7, 2023
1 parent e0d6b08 commit c88d3ef
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package net.jsign.appx;

import java.io.IOException;
import java.nio.BufferUnderflowException;
import java.nio.ByteBuffer;

import static java.nio.ByteOrder.*;
Expand Down Expand Up @@ -62,17 +63,21 @@ public Zip64ExtendedInfoExtraField(long uncompressedSize, long compressedSize, l
@Override
protected void parse() throws IOException {
ByteBuffer buffer = ByteBuffer.wrap(data).order(LITTLE_ENDIAN);
if (uncompressedSize != -1) {
uncompressedSize = buffer.getLong();
}
if (compressedSize != -1) {
compressedSize = buffer.getLong();
}
if (localHeaderOffset != -1) {
localHeaderOffset = buffer.getLong();
}
if (diskNumberStart != -1) {
diskNumberStart = buffer.getInt();
try {
if (uncompressedSize != -1) {
uncompressedSize = buffer.getLong();
}
if (compressedSize != -1) {
compressedSize = buffer.getLong();
}
if (localHeaderOffset != -1) {
localHeaderOffset = buffer.getLong();
}
if (diskNumberStart != -1) {
diskNumberStart = buffer.getInt();
}
} catch (BufferUnderflowException e) {
throw new IOException("Invalid ZIP64 extended information extra field", e);
}
}

Expand Down
Binary file not shown.

0 comments on commit c88d3ef

Please sign in to comment.