aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/poi/poifs
diff options
context:
space:
mode:
authorTim Allison <tallison@apache.org>2020-01-07 15:45:07 +0000
committerTim Allison <tallison@apache.org>2020-01-07 15:45:07 +0000
commite875bd81435bc7627e4eab9a18490583d2cee604 (patch)
tree20758df22e37ea06f7076fb0d4695a750bc90d83 /src/java/org/apache/poi/poifs
parentfb8f17190064f39f8f35700aa6ba1fbc2cfd88e1 (diff)
downloadpoi-e875bd81435bc7627e4eab9a18490583d2cee604.tar.gz
poi-e875bd81435bc7627e4eab9a18490583d2cee604.zip
BUG 64015 -- swap out java.util.BitSet for zaxxer's SparseBitSet
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1872445 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/poi/poifs')
-rw-r--r--src/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java10
-rw-r--r--src/java/org/apache/poi/poifs/crypt/xor/XOREncryptor.java4
2 files changed, 7 insertions, 7 deletions
diff --git a/src/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java b/src/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java
index b98e229d8e..e00b1c2bac 100644
--- a/src/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java
+++ b/src/java/org/apache/poi/poifs/crypt/ChunkedCipherOutputStream.java
@@ -25,13 +25,13 @@ import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.security.GeneralSecurityException;
-import java.util.BitSet;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.ShortBufferException;
+import com.zaxxer.sparsebits.SparseBitSet;
import org.apache.poi.EncryptedDocumentException;
import org.apache.poi.poifs.filesystem.DirectoryNode;
import org.apache.poi.poifs.filesystem.POIFSWriterEvent;
@@ -56,7 +56,7 @@ public abstract class ChunkedCipherOutputStream extends FilterOutputStream {
private final int chunkBits;
private final byte[] chunk;
- private final BitSet plainByteFlags;
+ private final SparseBitSet plainByteFlags;
private final File fileOut;
private final DirectoryNode dir;
@@ -74,7 +74,7 @@ public abstract class ChunkedCipherOutputStream extends FilterOutputStream {
this.chunkSize = chunkSize;
int cs = chunkSize == STREAMING ? 4096 : chunkSize;
this.chunk = IOUtils.safelyAllocate(cs, MAX_RECORD_LENGTH);
- this.plainByteFlags = new BitSet(cs);
+ this.plainByteFlags = new SparseBitSet(cs);
this.chunkBits = Integer.bitCount(cs-1);
this.fileOut = TempFile.createTempFile("encrypted_package", "crypt");
this.fileOut.deleteOnExit();
@@ -88,7 +88,7 @@ public abstract class ChunkedCipherOutputStream extends FilterOutputStream {
this.chunkSize = chunkSize;
int cs = chunkSize == STREAMING ? 4096 : chunkSize;
this.chunk = IOUtils.safelyAllocate(cs, MAX_RECORD_LENGTH);
- this.plainByteFlags = new BitSet(cs);
+ this.plainByteFlags = new SparseBitSet(cs);
this.chunkBits = Integer.bitCount(cs-1);
this.fileOut = null;
this.dir = null;
@@ -283,7 +283,7 @@ public abstract class ChunkedCipherOutputStream extends FilterOutputStream {
return chunk;
}
- protected BitSet getPlainByteFlags() {
+ protected SparseBitSet getPlainByteFlags() {
return plainByteFlags;
}
diff --git a/src/java/org/apache/poi/poifs/crypt/xor/XOREncryptor.java b/src/java/org/apache/poi/poifs/crypt/xor/XOREncryptor.java
index 3b180b20d4..0c1cbf4932 100644
--- a/src/java/org/apache/poi/poifs/crypt/xor/XOREncryptor.java
+++ b/src/java/org/apache/poi/poifs/crypt/xor/XOREncryptor.java
@@ -21,11 +21,11 @@ import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.security.GeneralSecurityException;
-import java.util.BitSet;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
+import com.zaxxer.sparsebits.SparseBitSet;
import org.apache.poi.EncryptedDocumentException;
import org.apache.poi.poifs.crypt.ChunkedCipherOutputStream;
import org.apache.poi.poifs.crypt.CryptoFunctions;
@@ -139,7 +139,7 @@ public class XOREncryptor extends Encryptor {
final int start = Math.max(posInChunk-(recordEnd-recordStart), 0);
- final BitSet plainBytes = getPlainByteFlags();
+ final SparseBitSet plainBytes = getPlainByteFlags();
final byte[] xorArray = getEncryptionInfo().getEncryptor().getSecretKey().getEncoded();
final byte[] chunk = getChunk();
final byte[] plain = (plainBytes.isEmpty()) ? null : chunk.clone();