Remove some unreachable code in CPDF_SecurityHandler.
Change-Id: I8250ffb2626a1662865f896c79141a690a29a138
Reviewed-on: https://pdfium-review.googlesource.com/c/48212
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/parser/cpdf_security_handler.cpp b/core/fpdfapi/parser/cpdf_security_handler.cpp
index 38e029c..bde69b6 100644
--- a/core/fpdfapi/parser/cpdf_security_handler.cpp
+++ b/core/fpdfapi/parser/cpdf_security_handler.cpp
@@ -321,8 +321,9 @@
bool CPDF_SecurityHandler::AES256_CheckPassword(const ByteString& password,
bool bOwner,
uint8_t* key) {
- if (!m_pEncryptDict)
- return false;
+ ASSERT(key);
+ ASSERT(m_pEncryptDict);
+ ASSERT(m_Revision >= 5);
ByteString okey = m_pEncryptDict->GetStringFor("O");
if (okey.GetLength() < 48)
@@ -349,9 +350,6 @@
if (memcmp(digest, pkey, 32) != 0)
return false;
- if (!key)
- return true;
-
if (m_Revision >= 6) {
Revision6_Hash(password, (const uint8_t*)pkey + 40,
bOwner ? ukey.raw_str() : nullptr, digest);
@@ -404,13 +402,11 @@
bool bOwner,
uint8_t* key,
int32_t key_len) {
+ ASSERT(key);
+
if (m_Revision >= 5)
return AES256_CheckPassword(password, bOwner, key);
- uint8_t keybuf[32];
- if (!key)
- key = keybuf;
-
if (bOwner)
return CheckOwnerPassword(password, key, key_len);