aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2015-12-30 20:31:23 +0000
committerDominik Stadler <centic@apache.org>2015-12-30 20:31:23 +0000
commitbaee1a559994e4684d02e7007955828b4538e0ec (patch)
treed1b30938d90e2f47a9f714bf2a38862a94b8fd17 /src
parenta40f3668d6c784e5245076b9d3a64911a5fbe1cc (diff)
downloadpoi-baee1a559994e4684d02e7007955828b4538e0ec.tar.gz
poi-baee1a559994e4684d02e7007955828b4538e0ec.zip
Bug 58616: Try to initialize with empty password if not done before
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1722407 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/integrationtest/org/apache/poi/TestAllFiles.java1
-rw-r--r--src/java/org/apache/poi/poifs/crypt/standard/StandardDecryptor.java3
-rw-r--r--src/ooxml/testcases/org/apache/poi/poifs/crypt/TestDecryptor.java11
3 files changed, 15 insertions, 0 deletions
diff --git a/src/integrationtest/org/apache/poi/TestAllFiles.java b/src/integrationtest/org/apache/poi/TestAllFiles.java
index bd77c3a2d1..39a2069b2c 100644
--- a/src/integrationtest/org/apache/poi/TestAllFiles.java
+++ b/src/integrationtest/org/apache/poi/TestAllFiles.java
@@ -199,6 +199,7 @@ public class TestAllFiles {
//EXPECTED_FAILURES.add("poifs/protected_sha512.xlsx");
//EXPECTED_FAILURES.add("poifs/extenxls_pwd123.xlsx");
//EXPECTED_FAILURES.add("poifs/protected_agile.docx");
+ EXPECTED_FAILURES.add("spreadsheet/58616.xlsx");
// TODO: fails XMLExportTest, is this ok?
EXPECTED_FAILURES.add("spreadsheet/CustomXMLMapping-singleattributenamespace.xlsx");
diff --git a/src/java/org/apache/poi/poifs/crypt/standard/StandardDecryptor.java b/src/java/org/apache/poi/poifs/crypt/standard/StandardDecryptor.java
index 1d6ddd398e..00d2f77e33 100644
--- a/src/java/org/apache/poi/poifs/crypt/standard/StandardDecryptor.java
+++ b/src/java/org/apache/poi/poifs/crypt/standard/StandardDecryptor.java
@@ -127,6 +127,9 @@ public class StandardDecryptor extends Decryptor {
_length = dis.readLong();
+ if(getSecretKey() == null) {
+ verifyPassword(null);
+ }
// limit wrong calculated ole entries - (bug #57080)
// standard encryption always uses aes encoding, so blockSize is always 16
// http://stackoverflow.com/questions/3283787/size-of-data-after-aes-encryption
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 ed7df2ed81..d2260dc998 100644
--- a/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestDecryptor.java
+++ b/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestDecryptor.java
@@ -22,6 +22,7 @@ import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.security.GeneralSecurityException;
@@ -33,6 +34,7 @@ import org.apache.poi.poifs.filesystem.DirectoryNode;
import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.util.IOUtils;
+import org.apache.poi.xssf.XSSFTestDataSamples;
import org.junit.Test;
/**
@@ -151,4 +153,13 @@ public class TestDecryptor {
zis.close();
fs.close();
}
+
+ @Test
+ public void test58616() throws IOException, GeneralSecurityException {
+ POIFSFileSystem pfs = new POIFSFileSystem(new FileInputStream(XSSFTestDataSamples.getSampleFile("58616.xlsx")));
+ EncryptionInfo info = new EncryptionInfo(pfs);
+ Decryptor dec = Decryptor.getInstance(info);
+ //dec.verifyPassword(null);
+ dec.getDataStream(pfs);
+ }
} \ No newline at end of file