summaryrefslogtreecommitdiff
path: root/core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp
diff options
context:
space:
mode:
authorthestig <thestig@chromium.org>2016-05-23 15:06:59 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-23 15:06:59 -0700
commit27ddf161579f79510b361d0016ccc7f0cdffdc6d (patch)
treebc5a13661d288faeccc8471275059a9d5e8795bc /core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp
parent490d6128e6faef423fa6f965f792513e138bc04a (diff)
downloadpdfium-27ddf161579f79510b361d0016ccc7f0cdffdc6d.tar.xz
Distinguish between user and owner passwords.
BUG=pdfium:496 Review-Url: https://codereview.chromium.org/2005653002
Diffstat (limited to 'core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp')
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp32
1 files changed, 15 insertions, 17 deletions
diff --git a/core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp b/core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp
index d6416fb055..94ef042bc0 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp
@@ -67,15 +67,15 @@ void CalcEncryptKey(CPDF_Dictionary* pEncrypt,
} // namespace
-CPDF_SecurityHandler::CPDF_SecurityHandler() {
- m_Version = 0;
- m_Revision = 0;
- m_pParser = NULL;
- m_pEncryptDict = NULL;
- m_Permissions = 0;
- m_Cipher = FXCIPHER_NONE;
- m_KeyLen = 0;
-}
+CPDF_SecurityHandler::CPDF_SecurityHandler()
+ : m_Version(0),
+ m_Revision(0),
+ m_pParser(nullptr),
+ m_pEncryptDict(nullptr),
+ m_Permissions(0),
+ m_Cipher(FXCIPHER_NONE),
+ m_KeyLen(0),
+ m_bOwnerUnlocked(false) {}
CPDF_SecurityHandler::~CPDF_SecurityHandler() {}
@@ -94,23 +94,21 @@ FX_BOOL CPDF_SecurityHandler::OnInit(CPDF_Parser* pParser,
}
return CheckSecurity(m_KeyLen);
}
+
FX_BOOL CPDF_SecurityHandler::CheckSecurity(int32_t key_len) {
CFX_ByteString password = m_pParser->GetPassword();
- if (CheckPassword(password.raw_str(), password.GetLength(), TRUE,
+ if (!password.IsEmpty() &&
+ CheckPassword(password.raw_str(), password.GetLength(), TRUE,
m_EncryptKey, key_len)) {
- if (password.IsEmpty()) {
- if (!CheckPassword(password.raw_str(), password.GetLength(), FALSE,
- m_EncryptKey, key_len)) {
- return FALSE;
- }
- }
+ m_bOwnerUnlocked = true;
return TRUE;
}
return CheckPassword(password.raw_str(), password.GetLength(), FALSE,
m_EncryptKey, key_len);
}
+
uint32_t CPDF_SecurityHandler::GetPermissions() {
- return m_Permissions;
+ return m_bOwnerUnlocked ? 0xFFFFFFFF : m_Permissions;
}
static FX_BOOL LoadCryptInfo(CPDF_Dictionary* pEncryptDict,