[bug-69563] try to avoid int overflow in Zip64 code (probably just moves the problem somewhere else though)

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1923647 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2025-02-07 21:44:50 +00:00
parent d8ae576afa
commit bc11cc335e
2 changed files with 6 additions and 6 deletions

View File

@ -37,7 +37,7 @@ class OpcOutputStream extends DeflaterOutputStream {
private final List<Entry> entries = new ArrayList<>();
private final CRC32 crc = new CRC32();
private Entry current;
private int written = 0;
private long written = 0;
private boolean finished = false;
/**
@ -84,7 +84,7 @@ class OpcOutputStream extends DeflaterOutputStream {
}
current.size = def.getBytesRead();
current.compressedSize = Math.toIntExact(def.getBytesWritten());
current.compressedSize = def.getBytesWritten();
current.crc = crc.getValue();
written += current.compressedSize;
@ -106,7 +106,7 @@ class OpcOutputStream extends DeflaterOutputStream {
if(current != null) {
closeEntry();
}
int offset = written;
long offset = written;
for (Entry entry : entries) {
written += spec.writeCEN(entry);
}

View File

@ -46,8 +46,8 @@ class Zip64Impl {
final String filename;
long crc;
long size;
int compressedSize;
int offset;
long compressedSize;
long offset;
Entry(String filename) {
this.filename = filename;
@ -128,7 +128,7 @@ class Zip64Impl {
/**
* Write End of central directory record (EOCD)
*/
int writeEND(int entriesCount, int offset, int length) throws IOException {
int writeEND(int entriesCount, long offset, long length) throws IOException {
written = 0;
writeInt(PK0506); // "PK\005\006"
writeShort(0); // number of this disk