aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/poi/poifs/crypt
diff options
context:
space:
mode:
authorJaven O'Neal <onealj@apache.org>2017-10-18 14:08:43 +0000
committerJaven O'Neal <onealj@apache.org>2017-10-18 14:08:43 +0000
commitfac34b6740ae41756588c2e04e7087f9b1c238ca (patch)
treeb27bebd49bb723840b53ceeb075e7d69da23838b /src/java/org/apache/poi/poifs/crypt
parent2ef3af567ce9a248dafb5e1f74bdadc5456f9ab0 (diff)
downloadpoi-fac34b6740ae41756588c2e04e7087f9b1c238ca.tar.gz
poi-fac34b6740ae41756588c2e04e7087f9b1c238ca.zip
cleanup for r1812476: avoid NPEs from string.isEmpty()
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1812516 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/poi/poifs/crypt')
-rw-r--r--src/java/org/apache/poi/poifs/crypt/CryptoFunctions.java8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/java/org/apache/poi/poifs/crypt/CryptoFunctions.java b/src/java/org/apache/poi/poifs/crypt/CryptoFunctions.java
index 9273f53e0e..6a16e3f9dc 100644
--- a/src/java/org/apache/poi/poifs/crypt/CryptoFunctions.java
+++ b/src/java/org/apache/poi/poifs/crypt/CryptoFunctions.java
@@ -374,6 +374,10 @@ public class CryptoFunctions {
* @return the verifier (actually a short value)
*/
public static int createXorVerifier1(String password) {
+ if (password == null) {
+ throw new IllegalArgumentException("Password cannot be null");
+ }
+
byte[] arrByteChars = toAnsiPassword(password);
// SET Verifier TO 0x0000
@@ -412,6 +416,10 @@ public class CryptoFunctions {
* @see <a href="http://www.aspose.com/blogs/aspose-blogs/vladimir-averkin/archive/2007/08/20/funny-how-the-new-powerful-cryptography-implemented-in-word-2007-turns-it-into-a-perfect-tool-for-document-password-removal.html">Funny: How the new powerful cryptography implemented in Word 2007 turns it into a perfect tool for document password removal.</a>
*/
public static int createXorVerifier2(String password) {
+ if (password == null) {
+ throw new IllegalArgumentException("Password cannot be null");
+ }
+
//Array to hold Key Values
byte[] generatedKey = new byte[4];