]> source.dussan.org Git - poi.git/commitdiff
Bug 58616: Try to initialize with empty password if not done before
authorDominik Stadler <centic@apache.org>
Wed, 30 Dec 2015 20:31:23 +0000 (20:31 +0000)
committerDominik Stadler <centic@apache.org>
Wed, 30 Dec 2015 20:31:23 +0000 (20:31 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1722407 13f79535-47bb-0310-9956-ffa450edef68

src/integrationtest/org/apache/poi/TestAllFiles.java
src/java/org/apache/poi/poifs/crypt/standard/StandardDecryptor.java
src/ooxml/testcases/org/apache/poi/poifs/crypt/TestDecryptor.java
test-data/spreadsheet/58616.xlsx [new file with mode: 0644]

index bd77c3a2d18f3928cf66f3e899cf004ed7ffbf40..39a2069b2c4e6aff450c087bcf5a5ca1f7061b8b 100644 (file)
@@ -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");
index 1d6ddd398e56fb7e014e588458f58d3611ebf5e9..00d2f77e33fb9d9fc00189de92dda1df1741ebd2 100644 (file)
@@ -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
index ed7df2ed813c9e39a4ba5f5ad11c5e962d2c1e5e..d2260dc99824b7165e91fc7cdddb2057c4f8cc29 100644 (file)
@@ -22,6 +22,7 @@ import static org.junit.Assert.assertTrue;
 import java.io.ByteArrayInputStream;\r
 import java.io.ByteArrayOutputStream;\r
 import java.io.File;\r
+import java.io.FileInputStream;\r
 import java.io.IOException;\r
 import java.io.InputStream;\r
 import java.security.GeneralSecurityException;\r
@@ -33,6 +34,7 @@ import org.apache.poi.poifs.filesystem.DirectoryNode;
 import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;\r
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;\r
 import org.apache.poi.util.IOUtils;\r
+import org.apache.poi.xssf.XSSFTestDataSamples;\r
 import org.junit.Test;\r
 \r
 /**\r
@@ -151,4 +153,13 @@ public class TestDecryptor {
         zis.close();\r
         fs.close();\r
     }\r
+\r
+    @Test\r
+    public void test58616() throws IOException, GeneralSecurityException {\r
+        POIFSFileSystem pfs = new POIFSFileSystem(new FileInputStream(XSSFTestDataSamples.getSampleFile("58616.xlsx")));                \r
+        EncryptionInfo info = new EncryptionInfo(pfs);             \r
+        Decryptor dec = Decryptor.getInstance(info);   \r
+        //dec.verifyPassword(null);\r
+        dec.getDataStream(pfs);\r
+    }\r
 }
\ No newline at end of file
diff --git a/test-data/spreadsheet/58616.xlsx b/test-data/spreadsheet/58616.xlsx
new file mode 100644 (file)
index 0000000..9ab5739
Binary files /dev/null and b/test-data/spreadsheet/58616.xlsx differ