aboutsummaryrefslogtreecommitdiffstats
path: root/poi
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2023-09-13 10:59:54 +0000
committerDominik Stadler <centic@apache.org>2023-09-13 10:59:54 +0000
commitcc4ccbae1d5389d5c973be997171f04fe5a7c4bb (patch)
tree5fa89ddde75e66db6a511e5fc3af47c22983f1f4 /poi
parent4b70989156fd31dd9b8fe8eeceea70553330293a (diff)
downloadpoi-cc4ccbae1d5389d5c973be997171f04fe5a7c4bb.tar.gz
poi-cc4ccbae1d5389d5c973be997171f04fe5a7c4bb.zip
Bug 66425: Avoid NullPointerExceptions found via poi-fuzz
We try to avoid throwing NullPointerException, but it was possible to trigger one here git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1912281 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi')
-rw-r--r--poi/src/main/java/org/apache/poi/poifs/crypt/CryptoFunctions.java6
1 files changed, 6 insertions, 0 deletions
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);
}