diff options
author | Andreas Beeker <kiwiwings@apache.org> | 2014-10-13 23:42:33 +0000 |
---|---|---|
committer | Andreas Beeker <kiwiwings@apache.org> | 2014-10-13 23:42:33 +0000 |
commit | 860892e68dc972922d589634c44bf2d54bb4ace2 (patch) | |
tree | b9034f4704751d0ef3816b354b1ab9e0af75646f /src/ooxml/testcases/org/apache/poi/poifs/crypt | |
parent | 8aab89c3ff22efcd8b7e455b48ec1e851759f27e (diff) | |
download | poi-860892e68dc972922d589634c44bf2d54bb4ace2.tar.gz poi-860892e68dc972922d589634c44bf2d54bb4ace2.zip |
Bug 57080 - IndexOutOfBoundsException in poi decryptor
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1631600 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/testcases/org/apache/poi/poifs/crypt')
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/poifs/crypt/TestDecryptor.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestDecryptor.java b/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestDecryptor.java index 48bc7a15a3..d0f2c67f51 100644 --- a/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestDecryptor.java +++ b/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestDecryptor.java @@ -20,6 +20,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.security.GeneralSecurityException;
@@ -27,7 +29,9 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream;
import org.apache.poi.POIDataSamples;
+import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+import org.apache.poi.util.IOUtils;
import org.junit.Test;
/**
@@ -122,4 +126,25 @@ public class TestDecryptor { }
}
+ @Test
+ public void bug57080() throws Exception {
+ // the test file contains a wrong ole entry size, produced by extenxls
+ // the fix limits the available size and tries to read all entries
+ File f = POIDataSamples.getPOIFSInstance().getFile("extenxls_pwd123.xlsx");
+ NPOIFSFileSystem fs = new NPOIFSFileSystem(f, true);
+ EncryptionInfo info = new EncryptionInfo(fs);
+ Decryptor d = Decryptor.getInstance(info);
+ d.verifyPassword("pwd123");
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ ZipInputStream zis = new ZipInputStream(d.getDataStream(fs));
+ ZipEntry ze;
+ while ((ze = zis.getNextEntry()) != null) {
+ bos.reset();
+ IOUtils.copy(zis, bos);
+ assertEquals(ze.getSize(), bos.size());
+ }
+
+ zis.close();
+ fs.close();
+ }
}
\ No newline at end of file |