diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-04-03 15:05:11 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-04-03 20:39:56 +0000 |
commit | 1c5d0b48ec7a6443ba72fec2a58a65fc6d694aca (patch) | |
tree | 315955cce6b29093dcddfc48c0811957a172bedf /core/fpdfapi/parser | |
parent | 2ae80f52cec81c080515724f99deb06b2fee3cc9 (diff) | |
download | pdfium-1c5d0b48ec7a6443ba72fec2a58a65fc6d694aca.tar.xz |
Drop FXSYS_ from mem methods
This Cl drops the FXSYS_ from mem methods which are the same on all
platforms.
Bug: pdfium:694
Change-Id: I9d5ae905997dbaaec5aa0b2ae4c07358ed9c6236
Reviewed-on: https://pdfium-review.googlesource.com/3613
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fpdfapi/parser')
-rw-r--r-- | core/fpdfapi/parser/cpdf_crypto_handler.cpp | 31 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_document.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_object_unittest.cpp | 4 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_parser.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_security_handler.cpp | 46 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_stream.cpp | 6 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_stream_acc.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_syntax_parser.cpp | 11 | ||||
-rw-r--r-- | core/fpdfapi/parser/fpdf_parser_decode.cpp | 8 |
9 files changed, 55 insertions, 57 deletions
diff --git a/core/fpdfapi/parser/cpdf_crypto_handler.cpp b/core/fpdfapi/parser/cpdf_crypto_handler.cpp index 61f78c4ee5..4fc7b3039b 100644 --- a/core/fpdfapi/parser/cpdf_crypto_handler.cpp +++ b/core/fpdfapi/parser/cpdf_crypto_handler.cpp @@ -21,7 +21,7 @@ void CPDF_CryptoHandler::CryptBlock(bool bEncrypt, uint8_t* dest_buf, uint32_t& dest_size) { if (m_Cipher == FXCIPHER_NONE) { - FXSYS_memcpy(dest_buf, src_buf, src_size); + memcpy(dest_buf, src_buf, src_size); return; } uint8_t realkey[16]; @@ -31,7 +31,7 @@ void CPDF_CryptoHandler::CryptBlock(bool bEncrypt, PopulateKey(objnum, gennum, key1); if (m_Cipher == FXCIPHER_AES) { - FXSYS_memcpy(key1 + m_KeyLen + 5, "sAlT", 4); + memcpy(key1 + m_KeyLen + 5, "sAlT", 4); } CRYPT_MD5Generate( key1, m_Cipher == FXCIPHER_AES ? m_KeyLen + 9 : m_KeyLen + 5, realkey); @@ -49,13 +49,12 @@ void CPDF_CryptoHandler::CryptBlock(bool bEncrypt, iv[i] = (uint8_t)rand(); } CRYPT_AESSetIV(m_pAESContext, iv); - FXSYS_memcpy(dest_buf, iv, 16); + memcpy(dest_buf, iv, 16); int nblocks = src_size / 16; CRYPT_AESEncrypt(m_pAESContext, dest_buf + 16, src_buf, nblocks * 16); uint8_t padding[16]; - FXSYS_memcpy(padding, src_buf + nblocks * 16, src_size % 16); - FXSYS_memset(padding + src_size % 16, 16 - src_size % 16, - 16 - src_size % 16); + memcpy(padding, src_buf + nblocks * 16, src_size % 16); + memset(padding + src_size % 16, 16 - src_size % 16, 16 - src_size % 16); CRYPT_AESEncrypt(m_pAESContext, dest_buf + nblocks * 16 + 16, padding, 16); dest_size = 32 + nblocks * 16; @@ -68,7 +67,7 @@ void CPDF_CryptoHandler::CryptBlock(bool bEncrypt, } else { ASSERT(dest_size == src_size); if (dest_buf != src_buf) { - FXSYS_memcpy(dest_buf, src_buf, src_size); + memcpy(dest_buf, src_buf, src_size); } CRYPT_ArcFourCryptBlock(dest_buf, dest_size, realkey, realkeylen); } @@ -104,7 +103,7 @@ void* CPDF_CryptoHandler::CryptStart(uint32_t objnum, PopulateKey(objnum, gennum, key1); if (m_Cipher == FXCIPHER_AES) { - FXSYS_memcpy(key1 + m_KeyLen + 5, "sAlT", 4); + memcpy(key1 + m_KeyLen + 5, "sAlT", 4); } uint8_t realkey[16]; CRYPT_MD5Generate( @@ -162,8 +161,8 @@ bool CPDF_CryptoHandler::CryptStream(void* context, if (copy_size > src_left) { copy_size = src_left; } - FXSYS_memcpy(pContext->m_Block + pContext->m_BlockOffset, src_buf + src_off, - copy_size); + memcpy(pContext->m_Block + pContext->m_BlockOffset, src_buf + src_off, + copy_size); src_off += copy_size; src_left -= copy_size; pContext->m_BlockOffset += copy_size; @@ -212,9 +211,9 @@ bool CPDF_CryptoHandler::CryptFinish(void* context, dest_buf.AppendBlock(block_buf, 16); pContext->m_BlockOffset = 0; } - FXSYS_memset(pContext->m_Block + pContext->m_BlockOffset, - (uint8_t)(16 - pContext->m_BlockOffset), - 16 - pContext->m_BlockOffset); + memset(pContext->m_Block + pContext->m_BlockOffset, + (uint8_t)(16 - pContext->m_BlockOffset), + 16 - pContext->m_BlockOffset); CRYPT_AESEncrypt(pContext->m_Context, block_buf, pContext->m_Block, 16); dest_buf.AppendBlock(block_buf, 16); } else if (pContext->m_BlockOffset == 16) { @@ -255,7 +254,7 @@ bool CPDF_CryptoHandler::Init(CPDF_Dictionary* pEncryptDict, return false; } if (m_Cipher != FXCIPHER_NONE) { - FXSYS_memcpy(m_EncryptKey, key, m_KeyLen); + memcpy(m_EncryptKey, key, m_KeyLen); } if (m_Cipher == FXCIPHER_AES) { m_pAESContext = FX_Alloc(uint8_t, 2048); @@ -288,7 +287,7 @@ bool CPDF_CryptoHandler::Init(int cipher, const uint8_t* key, int keylen) { } m_Cipher = cipher; m_KeyLen = keylen; - FXSYS_memcpy(m_EncryptKey, key, keylen); + memcpy(m_EncryptKey, key, keylen); if (m_Cipher == FXCIPHER_AES) { m_pAESContext = FX_Alloc(uint8_t, 2048); } @@ -333,7 +332,7 @@ CPDF_CryptoHandler::~CPDF_CryptoHandler() { void CPDF_CryptoHandler::PopulateKey(uint32_t objnum, uint32_t gennum, uint8_t* key) { - FXSYS_memcpy(key, m_EncryptKey, m_KeyLen); + memcpy(key, m_EncryptKey, m_KeyLen); key[m_KeyLen + 0] = (uint8_t)objnum; key[m_KeyLen + 1] = (uint8_t)(objnum >> 8); key[m_KeyLen + 2] = (uint8_t)(objnum >> 16); diff --git a/core/fpdfapi/parser/cpdf_document.cpp b/core/fpdfapi/parser/cpdf_document.cpp index 975592d044..b336acaf84 100644 --- a/core/fpdfapi/parser/cpdf_document.cpp +++ b/core/fpdfapi/parser/cpdf_document.cpp @@ -961,7 +961,7 @@ CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTW* pLogFont, bool bVert, bool bTranslateName) { LOGFONTA lfa; - FXSYS_memcpy(&lfa, pLogFont, (char*)lfa.lfFaceName - (char*)&lfa); + memcpy(&lfa, pLogFont, (char*)lfa.lfFaceName - (char*)&lfa); CFX_ByteString face = CFX_ByteString::FromUnicode(pLogFont->lfFaceName); if (face.GetLength() >= LF_FACESIZE) return nullptr; diff --git a/core/fpdfapi/parser/cpdf_object_unittest.cpp b/core/fpdfapi/parser/cpdf_object_unittest.cpp index 3b5374b637..1923992d7a 100644 --- a/core/fpdfapi/parser/cpdf_object_unittest.cpp +++ b/core/fpdfapi/parser/cpdf_object_unittest.cpp @@ -162,8 +162,8 @@ class PDFObjectsTest : public testing::Test { // streams need to be handled. if (!stream1->IsMemoryBased() || !stream2->IsMemoryBased()) return false; - return FXSYS_memcmp(stream1->GetRawData(), stream2->GetRawData(), - stream1->GetRawSize()) == 0; + return memcmp(stream1->GetRawData(), stream2->GetRawData(), + stream1->GetRawSize()) == 0; } case CPDF_Object::REFERENCE: return obj1->AsReference()->GetRefObjNum() == diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp index 323f91779c..cac678762d 100644 --- a/core/fpdfapi/parser/cpdf_parser.cpp +++ b/core/fpdfapi/parser/cpdf_parser.cpp @@ -1217,7 +1217,7 @@ void CPDF_Parser::GetIndirectBinary(uint32_t objnum, } pBuffer = FX_Alloc(uint8_t, size); - FXSYS_memcpy(pBuffer, pData + thisoff + offset, size); + memcpy(pBuffer, pData + thisoff + offset, size); return; } return; diff --git a/core/fpdfapi/parser/cpdf_security_handler.cpp b/core/fpdfapi/parser/cpdf_security_handler.cpp index cfc51350d9..44042cb47c 100644 --- a/core/fpdfapi/parser/cpdf_security_handler.cpp +++ b/core/fpdfapi/parser/cpdf_security_handler.cpp @@ -66,8 +66,8 @@ void CalcEncryptKey(CPDF_Dictionary* pEncrypt, CRYPT_MD5Generate(digest, copy_len, digest); } } - FXSYS_memset(key, 0, keylen); - FXSYS_memcpy(key, digest, copy_len); + memset(key, 0, keylen); + memcpy(key, digest, copy_len); } } // namespace @@ -303,7 +303,7 @@ void Revision6_Hash(const uint8_t* password, } FX_Free(aes); if (hash) { - FXSYS_memcpy(hash, input, 32); + memcpy(hash, input, 32); } } @@ -337,7 +337,7 @@ bool CPDF_SecurityHandler::AES256_CheckPassword(const uint8_t* password, CRYPT_SHA256Finish(&sha, digest); } - if (FXSYS_memcmp(digest, pkey, 32) != 0) + if (memcmp(digest, pkey, 32) != 0) return false; if (!key) @@ -364,7 +364,7 @@ bool CPDF_SecurityHandler::AES256_CheckPassword(const uint8_t* password, std::vector<uint8_t> aes(2048); CRYPT_AESSetKey(aes.data(), 16, digest, 32, false); uint8_t iv[16]; - FXSYS_memset(iv, 0, 16); + memset(iv, 0, 16); CRYPT_AESSetIV(aes.data(), iv); CRYPT_AESDecrypt(aes.data(), key, ekey.raw_str(), 32); CRYPT_AESSetKey(aes.data(), 16, key, 32, false); @@ -374,10 +374,10 @@ bool CPDF_SecurityHandler::AES256_CheckPassword(const uint8_t* password, return false; uint8_t perms_buf[16]; - FXSYS_memset(perms_buf, 0, sizeof(perms_buf)); + memset(perms_buf, 0, sizeof(perms_buf)); size_t copy_len = std::min(sizeof(perms_buf), static_cast<size_t>(perms.GetLength())); - FXSYS_memcpy(perms_buf, perms.raw_str(), copy_len); + memcpy(perms_buf, perms.raw_str(), copy_len); uint8_t buf[16]; CRYPT_AESDecrypt(aes.data(), buf, perms_buf, 16); if (buf[9] != 'a' || buf[10] != 'd' || buf[11] != 'b') @@ -425,7 +425,7 @@ bool CPDF_SecurityHandler::CheckUserPassword(const uint8_t* password, } uint8_t ukeybuf[32]; if (m_Revision == 2) { - FXSYS_memcpy(ukeybuf, defpasscode, 32); + memcpy(ukeybuf, defpasscode, 32); CRYPT_ArcFourCryptBlock(ukeybuf, 32, key, key_len); } else { uint8_t test[32], tmpkey[32]; @@ -433,9 +433,9 @@ bool CPDF_SecurityHandler::CheckUserPassword(const uint8_t* password, if (copy_len > (uint32_t)ukey.GetLength()) { copy_len = ukey.GetLength(); } - FXSYS_memset(test, 0, sizeof(test)); - FXSYS_memset(tmpkey, 0, sizeof(tmpkey)); - FXSYS_memcpy(test, ukey.c_str(), copy_len); + memset(test, 0, sizeof(test)); + memset(tmpkey, 0, sizeof(tmpkey)); + memcpy(test, ukey.c_str(), copy_len); for (int32_t i = 19; i >= 0; i--) { for (int j = 0; j < key_len; j++) tmpkey[j] = key[j] ^ static_cast<uint8_t>(i); @@ -450,9 +450,9 @@ bool CPDF_SecurityHandler::CheckUserPassword(const uint8_t* password, CRYPT_MD5Update(&md5, (uint8_t*)id.c_str(), id.GetLength()); } CRYPT_MD5Finish(&md5, ukeybuf); - return FXSYS_memcmp(test, ukeybuf, 16) == 0; + return memcmp(test, ukeybuf, 16) == 0; } - if (FXSYS_memcmp((void*)ukey.c_str(), ukeybuf, 16) == 0) { + if (memcmp((void*)ukey.c_str(), ukeybuf, 16) == 0) { return true; } return false; @@ -473,25 +473,25 @@ CFX_ByteString CPDF_SecurityHandler::GetUserPassword(const uint8_t* owner_pass, } } uint8_t enckey[32]; - FXSYS_memset(enckey, 0, sizeof(enckey)); + memset(enckey, 0, sizeof(enckey)); uint32_t copy_len = key_len; if (copy_len > sizeof(digest)) { copy_len = sizeof(digest); } - FXSYS_memcpy(enckey, digest, copy_len); + memcpy(enckey, digest, copy_len); int okeylen = okey.GetLength(); if (okeylen > 32) { okeylen = 32; } uint8_t okeybuf[64]; - FXSYS_memset(okeybuf, 0, sizeof(okeybuf)); - FXSYS_memcpy(okeybuf, okey.c_str(), okeylen); + memset(okeybuf, 0, sizeof(okeybuf)); + memcpy(okeybuf, okey.c_str(), okeylen); if (m_Revision == 2) { CRYPT_ArcFourCryptBlock(okeybuf, okeylen, enckey, key_len); } else { for (int32_t i = 19; i >= 0; i--) { uint8_t tempkey[32]; - FXSYS_memset(tempkey, 0, sizeof(tempkey)); + memset(tempkey, 0, sizeof(tempkey)); for (int j = 0; j < m_KeyLen; j++) tempkey[j] = enckey[j] ^ static_cast<uint8_t>(i); CRYPT_ArcFourCryptBlock(okeybuf, okeylen, tempkey, key_len); @@ -567,7 +567,7 @@ void CPDF_SecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict, CRYPT_MD5Generate(digest, 16, digest); } uint8_t enckey[32]; - FXSYS_memcpy(enckey, digest, key_len); + memcpy(enckey, digest, key_len); for (uint32_t i = 0; i < 32; i++) { passcode[i] = i < user_size ? user_pass[i] : defpasscode[i - user_size]; } @@ -587,7 +587,7 @@ void CPDF_SecurityHandler::OnCreate(CPDF_Dictionary* pEncryptDict, key_len, false, pIdArray); if (m_Revision < 3) { uint8_t tempbuf[32]; - FXSYS_memcpy(tempbuf, defpasscode, 32); + memcpy(tempbuf, defpasscode, 32); CRYPT_ArcFourCryptBlock(tempbuf, 32, m_EncryptKey, key_len); pEncryptDict->SetNewFor<CPDF_String>("U", CFX_ByteString(tempbuf, 32), false); @@ -660,7 +660,7 @@ void CPDF_SecurityHandler::AES256_SetPassword(CPDF_Dictionary* pEncryptDict, } CRYPT_SHA256Finish(&sha2, digest1); } - FXSYS_memcpy(digest1 + 32, digest, 16); + memcpy(digest1 + 32, digest, 16); pEncryptDict->SetNewFor<CPDF_String>(bOwner ? "O" : "U", CFX_ByteString(digest1, 48), false); if (m_Revision >= 6) { @@ -678,7 +678,7 @@ void CPDF_SecurityHandler::AES256_SetPassword(CPDF_Dictionary* pEncryptDict, uint8_t* aes = FX_Alloc(uint8_t, 2048); CRYPT_AESSetKey(aes, 16, digest1, 32, true); uint8_t iv[16]; - FXSYS_memset(iv, 0, 16); + memset(iv, 0, 16); CRYPT_AESSetIV(aes, iv); CRYPT_AESEncrypt(aes, digest1, key, 32); FX_Free(aes); @@ -706,7 +706,7 @@ void CPDF_SecurityHandler::AES256_SetPerms(CPDF_Dictionary* pEncryptDict, uint8_t* aes = FX_Alloc(uint8_t, 2048); CRYPT_AESSetKey(aes, 16, key, 32, true); uint8_t iv[16], buf1[16]; - FXSYS_memset(iv, 0, 16); + memset(iv, 0, 16); CRYPT_AESSetIV(aes, iv); CRYPT_AESEncrypt(aes, buf1, buf, 16); FX_Free(aes); diff --git a/core/fpdfapi/parser/cpdf_stream.cpp b/core/fpdfapi/parser/cpdf_stream.cpp index d62b45641b..532fd753f8 100644 --- a/core/fpdfapi/parser/cpdf_stream.cpp +++ b/core/fpdfapi/parser/cpdf_stream.cpp @@ -57,7 +57,7 @@ void CPDF_Stream::InitStream(const uint8_t* pData, m_pFile = nullptr; m_pDataBuf.reset(FX_Alloc(uint8_t, size)); if (pData) - FXSYS_memcpy(m_pDataBuf.get(), pData, size); + memcpy(m_pDataBuf.get(), pData, size); m_dwSize = size; if (m_pDict) m_pDict->SetNewFor<CPDF_Number>("Length", static_cast<int>(m_dwSize)); @@ -101,7 +101,7 @@ void CPDF_Stream::SetData(const uint8_t* pData, uint32_t size) { m_bMemoryBased = true; m_pDataBuf.reset(FX_Alloc(uint8_t, size)); if (pData) - FXSYS_memcpy(m_pDataBuf.get(), pData, size); + memcpy(m_pDataBuf.get(), pData, size); m_dwSize = size; if (!m_pDict) m_pDict = pdfium::MakeUnique<CPDF_Dictionary>(); @@ -117,7 +117,7 @@ bool CPDF_Stream::ReadRawData(FX_FILESIZE offset, return m_pFile->ReadBlock(buf, offset, size); if (m_pDataBuf) - FXSYS_memcpy(buf, m_pDataBuf.get() + offset, size); + memcpy(buf, m_pDataBuf.get() + offset, size); return true; } diff --git a/core/fpdfapi/parser/cpdf_stream_acc.cpp b/core/fpdfapi/parser/cpdf_stream_acc.cpp index 423de7c571..59ac289b7c 100644 --- a/core/fpdfapi/parser/cpdf_stream_acc.cpp +++ b/core/fpdfapi/parser/cpdf_stream_acc.cpp @@ -82,6 +82,6 @@ std::unique_ptr<uint8_t, FxFreeDeleter> CPDF_StreamAcc::DetachData() { return p; } std::unique_ptr<uint8_t, FxFreeDeleter> p(FX_Alloc(uint8_t, m_dwSize)); - FXSYS_memcpy(p.get(), m_pData, m_dwSize); + memcpy(p.get(), m_pData, m_dwSize); return p; } diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.cpp b/core/fpdfapi/parser/cpdf_syntax_parser.cpp index 54fb89a48b..67c0977cfe 100644 --- a/core/fpdfapi/parser/cpdf_syntax_parser.cpp +++ b/core/fpdfapi/parser/cpdf_syntax_parser.cpp @@ -645,13 +645,13 @@ std::unique_ptr<CPDF_Stream> CPDF_SyntaxParser::ReadStream( m_Pos = pos.ValueOrDie(); m_Pos += ReadEOLMarkers(m_Pos); - FXSYS_memset(m_WordBuffer, 0, kEndStreamStr.GetLength() + 1); + memset(m_WordBuffer, 0, kEndStreamStr.GetLength() + 1); GetNextWordInternal(nullptr); // Earlier version of PDF specification doesn't require EOL marker before // 'endstream' keyword. If keyword 'endstream' follows the bytes in // specified length, it signals the end of stream. - if (FXSYS_memcmp(m_WordBuffer, kEndStreamStr.raw_str(), - kEndStreamStr.GetLength()) == 0) { + if (memcmp(m_WordBuffer, kEndStreamStr.raw_str(), + kEndStreamStr.GetLength()) == 0) { bSearchForKeyword = false; } } @@ -750,14 +750,13 @@ std::unique_ptr<CPDF_Stream> CPDF_SyntaxParser::ReadStream( auto pStream = pdfium::MakeUnique<CPDF_Stream>(std::move(pData), len, std::move(pDict)); streamStartPos = m_Pos; - FXSYS_memset(m_WordBuffer, 0, kEndObjStr.GetLength() + 1); + memset(m_WordBuffer, 0, kEndObjStr.GetLength() + 1); GetNextWordInternal(nullptr); int numMarkers = ReadEOLMarkers(m_Pos); if (m_WordSize == static_cast<unsigned int>(kEndObjStr.GetLength()) && numMarkers != 0 && - FXSYS_memcmp(m_WordBuffer, kEndObjStr.raw_str(), - kEndObjStr.GetLength()) == 0) { + memcmp(m_WordBuffer, kEndObjStr.raw_str(), kEndObjStr.GetLength()) == 0) { m_Pos = streamStartPos; } return pStream; diff --git a/core/fpdfapi/parser/fpdf_parser_decode.cpp b/core/fpdfapi/parser/fpdf_parser_decode.cpp index af1f452afd..a1698aedde 100644 --- a/core/fpdfapi/parser/fpdf_parser_decode.cpp +++ b/core/fpdfapi/parser/fpdf_parser_decode.cpp @@ -114,7 +114,7 @@ uint32_t A85Decode(const uint8_t* src_buf, continue; if (ch == 'z') { - FXSYS_memset(dest_buf + dest_size, 0, 4); + memset(dest_buf + dest_size, 0, 4); state = 0; res = 0; dest_size += 4; @@ -226,9 +226,9 @@ uint32_t RunLengthDecode(const uint8_t* src_buf, if (buf_left < copy_len) { uint32_t delta = copy_len - buf_left; copy_len = buf_left; - FXSYS_memset(dest_buf + dest_count + copy_len, '\0', delta); + memset(dest_buf + dest_count + copy_len, '\0', delta); } - FXSYS_memcpy(dest_buf + dest_count, src_buf + i + 1, copy_len); + memcpy(dest_buf + dest_count, src_buf + i + 1, copy_len); dest_count += src_buf[i] + 1; i += src_buf[i] + 2; } else { @@ -236,7 +236,7 @@ uint32_t RunLengthDecode(const uint8_t* src_buf, if (i < src_size - 1) { fill = src_buf[i + 1]; } - FXSYS_memset(dest_buf + dest_count, fill, 257 - src_buf[i]); + memset(dest_buf + dest_count, fill, 257 - src_buf[i]); dest_count += 257 - src_buf[i]; i += 2; } |