Skip to content

Commit bc11cc3

Browse files
committed
[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
1 parent d8ae576 commit bc11cc3

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/OpcOutputStream.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class OpcOutputStream extends DeflaterOutputStream {
3737
private final List<Entry> entries = new ArrayList<>();
3838
private final CRC32 crc = new CRC32();
3939
private Entry current;
40-
private int written = 0;
40+
private long written = 0;
4141
private boolean finished = false;
4242

4343
/**
@@ -84,7 +84,7 @@ public void closeEntry() throws IOException {
8484
}
8585

8686
current.size = def.getBytesRead();
87-
current.compressedSize = Math.toIntExact(def.getBytesWritten());
87+
current.compressedSize = def.getBytesWritten();
8888
current.crc = crc.getValue();
8989

9090
written += current.compressedSize;
@@ -106,7 +106,7 @@ public void finish() throws IOException {
106106
if(current != null) {
107107
closeEntry();
108108
}
109-
int offset = written;
109+
long offset = written;
110110
for (Entry entry : entries) {
111111
written += spec.writeCEN(entry);
112112
}

poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/Zip64Impl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ static class Entry {
4646
final String filename;
4747
long crc;
4848
long size;
49-
int compressedSize;
50-
int offset;
49+
long compressedSize;
50+
long offset;
5151

5252
Entry(String filename) {
5353
this.filename = filename;
@@ -128,7 +128,7 @@ int writeCEN(Entry entry) throws IOException {
128128
/**
129129
* Write End of central directory record (EOCD)
130130
*/
131-
int writeEND(int entriesCount, int offset, int length) throws IOException {
131+
int writeEND(int entriesCount, long offset, long length) throws IOException {
132132
written = 0;
133133
writeInt(PK0506); // "PK\005\006"
134134
writeShort(0); // number of this disk

0 commit comments

Comments
 (0)