Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5145)

Unified Diff: core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp

Issue 2005653002: Distinguish between user and owner passwords. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp
diff --git a/core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp b/core/fpdfapi/fpdf_parser/cpdf_security_handler.cpp
index d6416fb05530d8506d364393806d6e739822c3ea..94ef042bc0a80ca6248cb851f65539cc1f301291 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,
« no previous file with comments | « core/fpdfapi/fpdf_parser/cpdf_security_handler.h ('k') | core/fpdfapi/fpdf_parser/cpdf_security_handler_embeddertest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698