]> source.dussan.org Git - poi.git/commitdiff
Avoid a NPE if no password was given - use the default office one instead
authorNick Burch <nick@apache.org>
Wed, 19 Jun 2013 11:56:21 +0000 (11:56 +0000)
committerNick Burch <nick@apache.org>
Wed, 19 Jun 2013 11:56:21 +0000 (11:56 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1494571 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/poifs/crypt/Decryptor.java

index f7ed16f87541a888b5293c30c0c54c604cf309df..9832ccea4079a675ce61aa75c68f970562246967 100644 (file)
@@ -96,6 +96,11 @@ public abstract class Decryptor {
 
     protected byte[] hashPassword(EncryptionInfo info,
                                   String password) throws NoSuchAlgorithmException {
+        // If no password was given, use the default
+        if (password == null) {
+            password = DEFAULT_PASSWORD;
+        }
+        
         MessageDigest sha1 = MessageDigest.getInstance("SHA-1");
         byte[] bytes;
         try {