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

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

Issue 2510223002: Make CPDF_Dictionary use unique pointers. (Closed)
Patch Set: rebase Created 4 years, 1 month 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
« no previous file with comments | « core/fpdfapi/parser/cpdf_parser.cpp ('k') | core/fpdfapi/parser/cpdf_stream.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfapi/parser/cpdf_security_handler.cpp
diff --git a/core/fpdfapi/parser/cpdf_security_handler.cpp b/core/fpdfapi/parser/cpdf_security_handler.cpp
index bebda4ded8c5cbd89bceaa17304ed2795cedb54e..f6f4aefa3fe1f5a3cc733db6eb8ffdb75d6f1a4d 100644
--- a/core/fpdfapi/parser/cpdf_security_handler.cpp
+++ b/core/fpdfapi/parser/cpdf_security_handler.cpp
@@ -8,12 +8,17 @@
#include <time.h>
+#include <algorithm>
+#include <utility>
+#include <vector>
+
#include "core/fdrm/crypto/fx_crypt.h"
#include "core/fpdfapi/parser/cpdf_array.h"
#include "core/fpdfapi/parser/cpdf_crypto_handler.h"
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_object.h"
#include "core/fpdfapi/parser/cpdf_parser.h"
+#include "core/fpdfapi/parser/cpdf_string.h"
namespace {
@@ -570,7 +575,8 @@ void CPDF_SecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict,
CRYPT_ArcFourCryptBlock(passcode, 32, tempkey, key_len);
}
}
- pEncryptDict->SetStringFor("O", CFX_ByteString(passcode, 32));
+ pEncryptDict->SetNewFor<CPDF_String>("O", CFX_ByteString(passcode, 32),
+ false);
}
CalcEncryptKey(m_pEncryptDict, (uint8_t*)user_pass, user_size, m_EncryptKey,
key_len, false, pIdArray);
@@ -578,7 +584,8 @@ void CPDF_SecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict,
uint8_t tempbuf[32];
FXSYS_memcpy(tempbuf, defpasscode, 32);
CRYPT_ArcFourCryptBlock(tempbuf, 32, m_EncryptKey, key_len);
- pEncryptDict->SetStringFor("U", CFX_ByteString(tempbuf, 32));
+ pEncryptDict->SetNewFor<CPDF_String>("U", CFX_ByteString(tempbuf, 32),
+ false);
} else {
uint8_t md5[100];
CRYPT_MD5Start(md5);
@@ -598,7 +605,8 @@ void CPDF_SecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict,
CRYPT_ArcFourCryptBlock(digest, 16, tempkey, key_len);
}
CRYPT_MD5Generate(digest, 16, digest + 16);
- pEncryptDict->SetStringFor("U", CFX_ByteString(digest, 32));
+ pEncryptDict->SetNewFor<CPDF_String>("U", CFX_ByteString(digest, 32),
+ false);
}
}
void CPDF_SecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict,
@@ -645,7 +653,8 @@ void CPDF_SecurityHandler::AES256_SetPassword(CPDF_Dictionary* pEncryptDict,
CRYPT_SHA256Finish(sha, digest1);
}
FXSYS_memcpy(digest1 + 32, digest, 16);
- pEncryptDict->SetStringFor(bOwner ? "O" : "U", CFX_ByteString(digest1, 48));
+ pEncryptDict->SetNewFor<CPDF_String>(bOwner ? "O" : "U",
+ CFX_ByteString(digest1, 48), false);
if (m_Revision >= 6) {
Revision6_Hash(password, size, digest + 8,
bOwner ? ukey.raw_str() : nullptr, digest1);
@@ -665,8 +674,10 @@ void CPDF_SecurityHandler::AES256_SetPassword(CPDF_Dictionary* pEncryptDict,
CRYPT_AESSetIV(aes, iv);
CRYPT_AESEncrypt(aes, digest1, key, 32);
FX_Free(aes);
- pEncryptDict->SetStringFor(bOwner ? "OE" : "UE", CFX_ByteString(digest1, 32));
+ pEncryptDict->SetNewFor<CPDF_String>(bOwner ? "OE" : "UE",
+ CFX_ByteString(digest1, 32), false);
}
+
void CPDF_SecurityHandler::AES256_SetPerms(CPDF_Dictionary* pEncryptDict,
uint32_t permissions,
bool bEncryptMetadata,
@@ -691,5 +702,6 @@ void CPDF_SecurityHandler::AES256_SetPerms(CPDF_Dictionary* pEncryptDict,
CRYPT_AESSetIV(aes, iv);
CRYPT_AESEncrypt(aes, buf1, buf, 16);
FX_Free(aes);
- pEncryptDict->SetStringFor("Perms", CFX_ByteString(buf1, 16));
+ pEncryptDict->SetNewFor<CPDF_String>("Perms", CFX_ByteString(buf1, 16),
+ false);
}
« no previous file with comments | « core/fpdfapi/parser/cpdf_parser.cpp ('k') | core/fpdfapi/parser/cpdf_stream.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698