diff options
-rw-r--r-- | poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFChartSheet.java | 5 | ||||
-rw-r--r-- | poi-ooxml/src/test/java/org/apache/poi/ss/tests/TestWorkbookFactory.java | 8 | ||||
-rw-r--r-- | poi/src/main/java/org/apache/poi/poifs/crypt/CryptoFunctions.java | 6 | ||||
-rw-r--r-- | test-data/spreadsheet/crash-274d6342e4842d61be0fb48eaadad6208ae767ae.xlsx | bin | 0 -> 6874 bytes | |||
-rw-r--r-- | test-data/spreadsheet/crash-9bf3cd4bd6f50a8a9339d363c2c7af14b536865c.xlsx | bin | 0 -> 8548 bytes | |||
-rw-r--r-- | test-data/spreadsheet/stress.xls | bin | 52224 -> 92160 bytes |
6 files changed, 17 insertions, 2 deletions
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFChartSheet.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFChartSheet.java index b9944a58d9..798cd4df7b 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFChartSheet.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFChartSheet.java @@ -90,8 +90,9 @@ public class XSSFChartSheet extends XSSFSheet { XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement( new QName(CTChartsheet.type.getName().getNamespaceURI(), "chartsheet")); - chartsheet.save(out, xmlOptions); - + if (chartsheet != null) { + chartsheet.save(out, xmlOptions); + } } private static byte[] blankWorksheet(){ diff --git a/poi-ooxml/src/test/java/org/apache/poi/ss/tests/TestWorkbookFactory.java b/poi-ooxml/src/test/java/org/apache/poi/ss/tests/TestWorkbookFactory.java index 200407e3ef..b306dc7712 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/ss/tests/TestWorkbookFactory.java +++ b/poi-ooxml/src/test/java/org/apache/poi/ss/tests/TestWorkbookFactory.java @@ -351,4 +351,12 @@ public final class TestWorkbookFactory { return false; } } + + @Test + void testEncryptionNullPointerException() throws IOException { + assertThrows(IllegalArgumentException.class, + () -> WorkbookFactory.create(POIDataSamples.getSpreadSheetInstance(). + openResourceAsStream( + "crash-9bf3cd4bd6f50a8a9339d363c2c7af14b536865c.xlsx"))); + } } diff --git a/poi/src/main/java/org/apache/poi/poifs/crypt/CryptoFunctions.java b/poi/src/main/java/org/apache/poi/poifs/crypt/CryptoFunctions.java index 587d72eca6..9a91165660 100644 --- a/poi/src/main/java/org/apache/poi/poifs/crypt/CryptoFunctions.java +++ b/poi/src/main/java/org/apache/poi/poifs/crypt/CryptoFunctions.java @@ -252,9 +252,15 @@ public final class CryptoFunctions { if (cipherAlgorithm == CipherAlgorithm.rc4) { cipher = Cipher.getInstance(cipherAlgorithm.jceId); } else if (cipherAlgorithm.needsBouncyCastle) { + if (chain == null) { + throw new IllegalArgumentException("Did not have a chain for cipher " + cipherAlgorithm); + } registerBouncyCastle(); cipher = Cipher.getInstance(cipherAlgorithm.jceId + "/" + chain.jceId + "/" + padding, "BC"); } else { + if (chain == null) { + throw new IllegalArgumentException("Did not have a chain for cipher " + cipherAlgorithm); + } cipher = Cipher.getInstance(cipherAlgorithm.jceId + "/" + chain.jceId + "/" + padding); } diff --git a/test-data/spreadsheet/crash-274d6342e4842d61be0fb48eaadad6208ae767ae.xlsx b/test-data/spreadsheet/crash-274d6342e4842d61be0fb48eaadad6208ae767ae.xlsx Binary files differnew file mode 100644 index 0000000000..0707db6706 --- /dev/null +++ b/test-data/spreadsheet/crash-274d6342e4842d61be0fb48eaadad6208ae767ae.xlsx diff --git a/test-data/spreadsheet/crash-9bf3cd4bd6f50a8a9339d363c2c7af14b536865c.xlsx b/test-data/spreadsheet/crash-9bf3cd4bd6f50a8a9339d363c2c7af14b536865c.xlsx Binary files differnew file mode 100644 index 0000000000..5c9421f628 --- /dev/null +++ b/test-data/spreadsheet/crash-9bf3cd4bd6f50a8a9339d363c2c7af14b536865c.xlsx diff --git a/test-data/spreadsheet/stress.xls b/test-data/spreadsheet/stress.xls Binary files differindex 4436b980e0..fb15d8174a 100644 --- a/test-data/spreadsheet/stress.xls +++ b/test-data/spreadsheet/stress.xls |