diff options
author | tsepez <tsepez@chromium.org> | 2016-04-08 14:38:54 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-04-08 14:38:54 -0700 |
commit | cfd4d57800835011b028435e064f13c29243d6e6 (patch) | |
tree | 59f3aa156ea2dca9ea4f5b0e964bd41fa4f9455e /core | |
parent | 4c3debb3c91f5842784be30a911b52cdabcab7df (diff) | |
download | pdfium-cfd4d57800835011b028435e064f13c29243d6e6.tar.xz |
Make converstion explicit from CFX_ByteString to uint8_t*
BUG=
Review URL: https://codereview.chromium.org/1868293002
Diffstat (limited to 'core')
-rw-r--r-- | core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/cpdf_colorspace.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.cpp | 42 | ||||
-rw-r--r-- | core/fxcrt/include/fx_string.h | 8 | ||||
-rw-r--r-- | core/fxge/ge/fx_ge_fontmap.cpp | 17 |
5 files changed, 33 insertions, 38 deletions
diff --git a/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp b/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp index c0d2ab0dd3..a337cf59ff 100644 --- a/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp +++ b/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp @@ -2011,7 +2011,7 @@ void CPDF_Creator::InitID(FX_BOOL bDefault) { CPDF_StandardSecurityHandler handler; CFX_ByteString user_pass = m_pParser->GetPassword(); uint32_t flag = PDF_ENCRYPT_CONTENT; - handler.OnCreate(m_pEncryptDict, m_pIDArray, (const uint8_t*)user_pass, + handler.OnCreate(m_pEncryptDict, m_pIDArray, user_pass.raw_str(), user_pass.GetLength(), flag); if (m_bNewCrypto) { delete m_pCryptoHandler; diff --git a/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp b/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp index b5dcd46235..79faebafc9 100644 --- a/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp @@ -1029,7 +1029,7 @@ FX_BOOL CPDF_IndexedCS::GetRGB(FX_FLOAT* pBuf, } CFX_FixedBufGrow<FX_FLOAT, 16> Comps(m_nBaseComponents); FX_FLOAT* comps = Comps; - const uint8_t* pTable = m_Table; + const uint8_t* pTable = m_Table.raw_str(); for (int i = 0; i < m_nBaseComponents; i++) { comps[i] = m_pCompMinMax[i * 2] + diff --git a/core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.cpp b/core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.cpp index b7ed0315bb..627ff5263f 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_standard_security_handler.cpp @@ -98,18 +98,18 @@ FX_BOOL CPDF_StandardSecurityHandler::OnInit(CPDF_Parser* pParser, } FX_BOOL CPDF_StandardSecurityHandler::CheckSecurity(int32_t key_len) { CFX_ByteString password = m_pParser->GetPassword(); - if (CheckPassword(password, password.GetLength(), TRUE, m_EncryptKey, - key_len)) { + if (CheckPassword(password.raw_str(), password.GetLength(), TRUE, + m_EncryptKey, key_len)) { if (password.IsEmpty()) { - if (!CheckPassword(password, password.GetLength(), FALSE, m_EncryptKey, - key_len)) { + if (!CheckPassword(password.raw_str(), password.GetLength(), FALSE, + m_EncryptKey, key_len)) { return FALSE; } } return TRUE; } - return CheckPassword(password, password.GetLength(), FALSE, m_EncryptKey, - key_len); + return CheckPassword(password.raw_str(), password.GetLength(), FALSE, + m_EncryptKey, key_len); } uint32_t CPDF_StandardSecurityHandler::GetPermissions() { return m_Permissions; @@ -320,18 +320,18 @@ FX_BOOL CPDF_StandardSecurityHandler::AES256_CheckPassword( if (ukey.GetLength() < 48) { return FALSE; } - const uint8_t* pkey = bOwner ? (const uint8_t*)okey : (const uint8_t*)ukey; + const uint8_t* pkey = (bOwner ? okey : ukey).raw_str(); uint8_t sha[128]; uint8_t digest[32]; if (m_Revision >= 6) { Revision6_Hash(password, size, (const uint8_t*)pkey + 32, - (bOwner ? (const uint8_t*)ukey : NULL), digest); + bOwner ? ukey.raw_str() : nullptr, digest); } else { CRYPT_SHA256Start(sha); CRYPT_SHA256Update(sha, password, size); CRYPT_SHA256Update(sha, pkey + 32, 8); if (bOwner) { - CRYPT_SHA256Update(sha, ukey, 48); + CRYPT_SHA256Update(sha, ukey.raw_str(), 48); } CRYPT_SHA256Finish(sha, digest); } @@ -343,13 +343,13 @@ FX_BOOL CPDF_StandardSecurityHandler::AES256_CheckPassword( } if (m_Revision >= 6) { Revision6_Hash(password, size, (const uint8_t*)pkey + 40, - (bOwner ? (const uint8_t*)ukey : NULL), digest); + bOwner ? ukey.raw_str() : nullptr, digest); } else { CRYPT_SHA256Start(sha); CRYPT_SHA256Update(sha, password, size); CRYPT_SHA256Update(sha, pkey + 40, 8); if (bOwner) { - CRYPT_SHA256Update(sha, ukey, 48); + CRYPT_SHA256Update(sha, ukey.raw_str(), 48); } CRYPT_SHA256Finish(sha, digest); } @@ -364,7 +364,7 @@ FX_BOOL CPDF_StandardSecurityHandler::AES256_CheckPassword( uint8_t iv[16]; FXSYS_memset(iv, 0, 16); CRYPT_AESSetIV(aes, iv); - CRYPT_AESDecrypt(aes, key, ekey, 32); + CRYPT_AESDecrypt(aes, key, ekey.raw_str(), 32); CRYPT_AESSetKey(aes, 16, key, 32, FALSE); CRYPT_AESSetIV(aes, iv); CFX_ByteString perms = m_pEncryptDict->GetStringBy("Perms"); @@ -377,7 +377,7 @@ FX_BOOL CPDF_StandardSecurityHandler::AES256_CheckPassword( if (copy_len > (uint32_t)perms.GetLength()) { copy_len = perms.GetLength(); } - FXSYS_memcpy(perms_buf, (const uint8_t*)perms, copy_len); + FXSYS_memcpy(perms_buf, perms.raw_str(), copy_len); uint8_t buf[16]; CRYPT_AESDecrypt(aes, buf, perms_buf, 16); FX_Free(aes); @@ -515,12 +515,12 @@ FX_BOOL CPDF_StandardSecurityHandler::CheckOwnerPassword( uint8_t* key, int32_t key_len) { CFX_ByteString user_pass = GetUserPassword(password, pass_size, key_len); - if (CheckUserPassword(user_pass, user_pass.GetLength(), FALSE, key, + if (CheckUserPassword(user_pass.raw_str(), user_pass.GetLength(), FALSE, key, key_len)) { return TRUE; } - return CheckUserPassword(user_pass, user_pass.GetLength(), TRUE, key, - key_len); + return CheckUserPassword(user_pass.raw_str(), user_pass.GetLength(), TRUE, + key, key_len); } FX_BOOL CPDF_StandardSecurityHandler::IsMetadataEncrypted() { return m_pEncryptDict->GetBooleanBy("EncryptMetadata", TRUE); @@ -652,14 +652,14 @@ void CPDF_StandardSecurityHandler::AES256_SetPassword( CFX_ByteString ukey = pEncryptDict->GetStringBy("U"); uint8_t digest1[48]; if (m_Revision >= 6) { - Revision6_Hash(password, size, digest, - (bOwner ? (const uint8_t*)ukey : NULL), digest1); + Revision6_Hash(password, size, digest, bOwner ? ukey.raw_str() : nullptr, + digest1); } else { CRYPT_SHA256Start(sha); CRYPT_SHA256Update(sha, password, size); CRYPT_SHA256Update(sha, digest, 8); if (bOwner) { - CRYPT_SHA256Update(sha, ukey, ukey.GetLength()); + CRYPT_SHA256Update(sha, ukey.raw_str(), ukey.GetLength()); } CRYPT_SHA256Finish(sha, digest1); } @@ -667,13 +667,13 @@ void CPDF_StandardSecurityHandler::AES256_SetPassword( pEncryptDict->SetAtString(bOwner ? "O" : "U", CFX_ByteString(digest1, 48)); if (m_Revision >= 6) { Revision6_Hash(password, size, digest + 8, - (bOwner ? (const uint8_t*)ukey : NULL), digest1); + bOwner ? ukey.raw_str() : nullptr, digest1); } else { CRYPT_SHA256Start(sha); CRYPT_SHA256Update(sha, password, size); CRYPT_SHA256Update(sha, digest + 8, 8); if (bOwner) { - CRYPT_SHA256Update(sha, ukey, ukey.GetLength()); + CRYPT_SHA256Update(sha, ukey.raw_str(), ukey.GetLength()); } CRYPT_SHA256Finish(sha, digest1); } diff --git a/core/fxcrt/include/fx_string.h b/core/fxcrt/include/fx_string.h index 5e3cb45fba..0e3160a9d8 100644 --- a/core/fxcrt/include/fx_string.h +++ b/core/fxcrt/include/fx_string.h @@ -180,12 +180,6 @@ class CFX_ByteString { : nullptr; } - // Implicit conversion to uint8_t* -- deprecated. - operator const uint8_t*() const { - return m_pData ? reinterpret_cast<const uint8_t*>(m_pData->m_String) - : nullptr; - } - // Explicit conversion to CFX_ByteStringC. // Note: |this| must outlive the use of the result. CFX_ByteStringC AsStringC() const { @@ -294,7 +288,7 @@ class CFX_ByteString { }; inline CFX_ByteStringC& CFX_ByteStringC::operator=(const CFX_ByteString& src) { - m_Ptr = (const uint8_t*)src; + m_Ptr = src.raw_str(); m_Length = src.GetLength(); return *this; } diff --git a/core/fxge/ge/fx_ge_fontmap.cpp b/core/fxge/ge/fx_ge_fontmap.cpp index 4ee2a22ae6..5ef58b5e79 100644 --- a/core/fxge/ge/fx_ge_fontmap.cpp +++ b/core/fxge/ge/fx_ge_fontmap.cpp @@ -751,7 +751,7 @@ void CFX_FontMapper::AddInstalledFont(const CFX_ByteString& name, int charset) { if (name == m_LastFamily) { return; } - const uint8_t* ptr = name; + const uint8_t* ptr = name.raw_str(); FX_BOOL bLocalized = FALSE; for (int i = 0; i < name.GetLength(); i++) if (ptr[i] > 0x80) { @@ -1464,15 +1464,16 @@ void CFX_FolderFontInfo::ReportFace(const CFX_ByteString& path, return; } CFX_ByteString names = - FPDF_LoadTableFromTT(pFile, tables, nTables, 0x6e616d65); + FPDF_LoadTableFromTT(pFile, tables.raw_str(), nTables, 0x6e616d65); if (names.IsEmpty()) { return; } - CFX_ByteString facename = GetNameFromTT(names, names.GetLength(), 1); + CFX_ByteString facename = + GetNameFromTT(names.raw_str(), names.GetLength(), 1); if (facename.IsEmpty()) { return; } - CFX_ByteString style = GetNameFromTT(names, names.GetLength(), 2); + CFX_ByteString style = GetNameFromTT(names.raw_str(), names.GetLength(), 2); if (style != "Regular") { facename += " " + style; } @@ -1481,9 +1482,10 @@ void CFX_FolderFontInfo::ReportFace(const CFX_ByteString& path, CFX_FontFaceInfo* pInfo = new CFX_FontFaceInfo(path, facename, tables, offset, filesize); - CFX_ByteString os2 = FPDF_LoadTableFromTT(pFile, tables, nTables, 0x4f532f32); + CFX_ByteString os2 = + FPDF_LoadTableFromTT(pFile, tables.raw_str(), nTables, 0x4f532f32); if (os2.GetLength() >= 86) { - const uint8_t* p = (const uint8_t*)os2 + 78; + const uint8_t* p = os2.raw_str() + 78; uint32_t codepages = GET_TT_LONG(p); if (codepages & (1 << 17)) { m_pMapper->AddInstalledFont(facename, FXFONT_SHIFTJIS_CHARSET); @@ -1603,8 +1605,7 @@ uint32_t CFX_FolderFontInfo::GetFontData(void* hFont, } else { uint32_t nTables = pFont->m_FontTables.GetLength() / 16; for (uint32_t i = 0; i < nTables; i++) { - const uint8_t* p = - static_cast<const uint8_t*>(pFont->m_FontTables) + i * 16; + const uint8_t* p = pFont->m_FontTables.raw_str() + i * 16; if (GET_TT_LONG(p) == table) { offset = GET_TT_LONG(p + 8); datasize = GET_TT_LONG(p + 12); |