From: Nick Burch Date: Wed, 19 Jun 2013 11:56:21 +0000 (+0000) Subject: Avoid a NPE if no password was given - use the default office one instead X-Git-Tag: 3.10-beta1~14 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0591f0edbebddaaa37afc8e8259be1fda37882af;p=poi.git Avoid a NPE if no password was given - use the default office one instead git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1494571 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/poi/poifs/crypt/Decryptor.java b/src/java/org/apache/poi/poifs/crypt/Decryptor.java index f7ed16f875..9832ccea40 100644 --- a/src/java/org/apache/poi/poifs/crypt/Decryptor.java +++ b/src/java/org/apache/poi/poifs/crypt/Decryptor.java @@ -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 {