| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "core/fpdfapi/fpdf_parser/cpdf_syntax_parser.h" | 7 #include "core/fpdfapi/fpdf_parser/cpdf_syntax_parser.h" |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" | 21 #include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" |
| 22 #include "core/fpdfapi/fpdf_parser/ipdf_crypto_handler.h" | 22 #include "core/fpdfapi/fpdf_parser/ipdf_crypto_handler.h" |
| 23 #include "core/fpdfapi/include/cpdf_modulemgr.h" | 23 #include "core/fpdfapi/include/cpdf_modulemgr.h" |
| 24 #include "core/fxcrt/include/fx_ext.h" | 24 #include "core/fxcrt/include/fx_ext.h" |
| 25 #include "third_party/base/numerics/safe_math.h" | 25 #include "third_party/base/numerics/safe_math.h" |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| 29 struct SearchTagRecord { | 29 struct SearchTagRecord { |
| 30 const char* m_pTag; | 30 const char* m_pTag; |
| 31 FX_DWORD m_Len; | 31 uint32_t m_Len; |
| 32 FX_DWORD m_Offset; | 32 uint32_t m_Offset; |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 } // namespace | 35 } // namespace |
| 36 | 36 |
| 37 // static | 37 // static |
| 38 int CPDF_SyntaxParser::s_CurrentRecursionDepth = 0; | 38 int CPDF_SyntaxParser::s_CurrentRecursionDepth = 0; |
| 39 | 39 |
| 40 CPDF_SyntaxParser::CPDF_SyntaxParser() | 40 CPDF_SyntaxParser::CPDF_SyntaxParser() |
| 41 : m_MetadataObjnum(0), | 41 : m_MetadataObjnum(0), |
| 42 m_pFileAccess(nullptr), | 42 m_pFileAccess(nullptr), |
| (...skipping 10 matching lines...) Expand all Loading... |
| 53 return GetNextChar(ch); | 53 return GetNextChar(ch); |
| 54 } | 54 } |
| 55 | 55 |
| 56 FX_BOOL CPDF_SyntaxParser::GetNextChar(uint8_t& ch) { | 56 FX_BOOL CPDF_SyntaxParser::GetNextChar(uint8_t& ch) { |
| 57 FX_FILESIZE pos = m_Pos + m_HeaderOffset; | 57 FX_FILESIZE pos = m_Pos + m_HeaderOffset; |
| 58 if (pos >= m_FileLen) | 58 if (pos >= m_FileLen) |
| 59 return FALSE; | 59 return FALSE; |
| 60 | 60 |
| 61 if (m_BufOffset >= pos || (FX_FILESIZE)(m_BufOffset + m_BufSize) <= pos) { | 61 if (m_BufOffset >= pos || (FX_FILESIZE)(m_BufOffset + m_BufSize) <= pos) { |
| 62 FX_FILESIZE read_pos = pos; | 62 FX_FILESIZE read_pos = pos; |
| 63 FX_DWORD read_size = m_BufSize; | 63 uint32_t read_size = m_BufSize; |
| 64 if ((FX_FILESIZE)read_size > m_FileLen) | 64 if ((FX_FILESIZE)read_size > m_FileLen) |
| 65 read_size = (FX_DWORD)m_FileLen; | 65 read_size = (uint32_t)m_FileLen; |
| 66 | 66 |
| 67 if ((FX_FILESIZE)(read_pos + read_size) > m_FileLen) { | 67 if ((FX_FILESIZE)(read_pos + read_size) > m_FileLen) { |
| 68 if (m_FileLen < (FX_FILESIZE)read_size) { | 68 if (m_FileLen < (FX_FILESIZE)read_size) { |
| 69 read_pos = 0; | 69 read_pos = 0; |
| 70 read_size = (FX_DWORD)m_FileLen; | 70 read_size = (uint32_t)m_FileLen; |
| 71 } else { | 71 } else { |
| 72 read_pos = m_FileLen - read_size; | 72 read_pos = m_FileLen - read_size; |
| 73 } | 73 } |
| 74 } | 74 } |
| 75 | 75 |
| 76 if (!m_pFileAccess->ReadBlock(m_pFileBuf, read_pos, read_size)) | 76 if (!m_pFileAccess->ReadBlock(m_pFileBuf, read_pos, read_size)) |
| 77 return FALSE; | 77 return FALSE; |
| 78 | 78 |
| 79 m_BufOffset = read_pos; | 79 m_BufOffset = read_pos; |
| 80 } | 80 } |
| 81 ch = m_pFileBuf[pos - m_BufOffset]; | 81 ch = m_pFileBuf[pos - m_BufOffset]; |
| 82 m_Pos++; | 82 m_Pos++; |
| 83 return TRUE; | 83 return TRUE; |
| 84 } | 84 } |
| 85 | 85 |
| 86 FX_BOOL CPDF_SyntaxParser::GetCharAtBackward(FX_FILESIZE pos, uint8_t& ch) { | 86 FX_BOOL CPDF_SyntaxParser::GetCharAtBackward(FX_FILESIZE pos, uint8_t& ch) { |
| 87 pos += m_HeaderOffset; | 87 pos += m_HeaderOffset; |
| 88 if (pos >= m_FileLen) | 88 if (pos >= m_FileLen) |
| 89 return FALSE; | 89 return FALSE; |
| 90 | 90 |
| 91 if (m_BufOffset >= pos || (FX_FILESIZE)(m_BufOffset + m_BufSize) <= pos) { | 91 if (m_BufOffset >= pos || (FX_FILESIZE)(m_BufOffset + m_BufSize) <= pos) { |
| 92 FX_FILESIZE read_pos; | 92 FX_FILESIZE read_pos; |
| 93 if (pos < (FX_FILESIZE)m_BufSize) | 93 if (pos < (FX_FILESIZE)m_BufSize) |
| 94 read_pos = 0; | 94 read_pos = 0; |
| 95 else | 95 else |
| 96 read_pos = pos - m_BufSize + 1; | 96 read_pos = pos - m_BufSize + 1; |
| 97 | 97 |
| 98 FX_DWORD read_size = m_BufSize; | 98 uint32_t read_size = m_BufSize; |
| 99 if ((FX_FILESIZE)(read_pos + read_size) > m_FileLen) { | 99 if ((FX_FILESIZE)(read_pos + read_size) > m_FileLen) { |
| 100 if (m_FileLen < (FX_FILESIZE)read_size) { | 100 if (m_FileLen < (FX_FILESIZE)read_size) { |
| 101 read_pos = 0; | 101 read_pos = 0; |
| 102 read_size = (FX_DWORD)m_FileLen; | 102 read_size = (uint32_t)m_FileLen; |
| 103 } else { | 103 } else { |
| 104 read_pos = m_FileLen - read_size; | 104 read_pos = m_FileLen - read_size; |
| 105 } | 105 } |
| 106 } | 106 } |
| 107 | 107 |
| 108 if (!m_pFileAccess->ReadBlock(m_pFileBuf, read_pos, read_size)) | 108 if (!m_pFileAccess->ReadBlock(m_pFileBuf, read_pos, read_size)) |
| 109 return FALSE; | 109 return FALSE; |
| 110 | 110 |
| 111 m_BufOffset = read_pos; | 111 m_BufOffset = read_pos; |
| 112 } | 112 } |
| 113 ch = m_pFileBuf[pos - m_BufOffset]; | 113 ch = m_pFileBuf[pos - m_BufOffset]; |
| 114 return TRUE; | 114 return TRUE; |
| 115 } | 115 } |
| 116 | 116 |
| 117 FX_BOOL CPDF_SyntaxParser::ReadBlock(uint8_t* pBuf, FX_DWORD size) { | 117 FX_BOOL CPDF_SyntaxParser::ReadBlock(uint8_t* pBuf, uint32_t size) { |
| 118 if (!m_pFileAccess->ReadBlock(pBuf, m_Pos + m_HeaderOffset, size)) | 118 if (!m_pFileAccess->ReadBlock(pBuf, m_Pos + m_HeaderOffset, size)) |
| 119 return FALSE; | 119 return FALSE; |
| 120 m_Pos += size; | 120 m_Pos += size; |
| 121 return TRUE; | 121 return TRUE; |
| 122 } | 122 } |
| 123 | 123 |
| 124 void CPDF_SyntaxParser::GetNextWordInternal(bool* bIsNumber) { | 124 void CPDF_SyntaxParser::GetNextWordInternal(bool* bIsNumber) { |
| 125 m_WordSize = 0; | 125 m_WordSize = 0; |
| 126 if (bIsNumber) | 126 if (bIsNumber) |
| 127 *bIsNumber = true; | 127 *bIsNumber = true; |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 CFX_ByteString CPDF_SyntaxParser::GetNextWord(bool* bIsNumber) { | 368 CFX_ByteString CPDF_SyntaxParser::GetNextWord(bool* bIsNumber) { |
| 369 GetNextWordInternal(bIsNumber); | 369 GetNextWordInternal(bIsNumber); |
| 370 return CFX_ByteString((const FX_CHAR*)m_WordBuffer, m_WordSize); | 370 return CFX_ByteString((const FX_CHAR*)m_WordBuffer, m_WordSize); |
| 371 } | 371 } |
| 372 | 372 |
| 373 CFX_ByteString CPDF_SyntaxParser::GetKeyword() { | 373 CFX_ByteString CPDF_SyntaxParser::GetKeyword() { |
| 374 return GetNextWord(nullptr); | 374 return GetNextWord(nullptr); |
| 375 } | 375 } |
| 376 | 376 |
| 377 CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjectHolder* pObjList, | 377 CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjectHolder* pObjList, |
| 378 FX_DWORD objnum, | 378 uint32_t objnum, |
| 379 FX_DWORD gennum, | 379 uint32_t gennum, |
| 380 FX_BOOL bDecrypt) { | 380 FX_BOOL bDecrypt) { |
| 381 CFX_AutoRestorer<int> restorer(&s_CurrentRecursionDepth); | 381 CFX_AutoRestorer<int> restorer(&s_CurrentRecursionDepth); |
| 382 if (++s_CurrentRecursionDepth > kParserMaxRecursionDepth) | 382 if (++s_CurrentRecursionDepth > kParserMaxRecursionDepth) |
| 383 return nullptr; | 383 return nullptr; |
| 384 | 384 |
| 385 FX_FILESIZE SavedPos = m_Pos; | 385 FX_FILESIZE SavedPos = m_Pos; |
| 386 bool bIsNumber; | 386 bool bIsNumber; |
| 387 CFX_ByteString word = GetNextWord(&bIsNumber); | 387 CFX_ByteString word = GetNextWord(&bIsNumber); |
| 388 if (word.GetLength() == 0) | 388 if (word.GetLength() == 0) |
| 389 return nullptr; | 389 return nullptr; |
| 390 | 390 |
| 391 if (bIsNumber) { | 391 if (bIsNumber) { |
| 392 FX_FILESIZE SavedPos = m_Pos; | 392 FX_FILESIZE SavedPos = m_Pos; |
| 393 CFX_ByteString nextword = GetNextWord(&bIsNumber); | 393 CFX_ByteString nextword = GetNextWord(&bIsNumber); |
| 394 if (bIsNumber) { | 394 if (bIsNumber) { |
| 395 CFX_ByteString nextword2 = GetNextWord(nullptr); | 395 CFX_ByteString nextword2 = GetNextWord(nullptr); |
| 396 if (nextword2 == "R") { | 396 if (nextword2 == "R") { |
| 397 FX_DWORD objnum = FXSYS_atoui(word); | 397 uint32_t objnum = FXSYS_atoui(word); |
| 398 return new CPDF_Reference(pObjList, objnum); | 398 return new CPDF_Reference(pObjList, objnum); |
| 399 } | 399 } |
| 400 } | 400 } |
| 401 m_Pos = SavedPos; | 401 m_Pos = SavedPos; |
| 402 return new CPDF_Number(word); | 402 return new CPDF_Number(word); |
| 403 } | 403 } |
| 404 | 404 |
| 405 if (word == "true" || word == "false") | 405 if (word == "true" || word == "false") |
| 406 return new CPDF_Boolean(word == "true"); | 406 return new CPDF_Boolean(word == "true"); |
| 407 | 407 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 } | 493 } |
| 494 | 494 |
| 495 if (word == ">>") | 495 if (word == ">>") |
| 496 m_Pos = SavedPos; | 496 m_Pos = SavedPos; |
| 497 | 497 |
| 498 return nullptr; | 498 return nullptr; |
| 499 } | 499 } |
| 500 | 500 |
| 501 CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict( | 501 CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict( |
| 502 CPDF_IndirectObjectHolder* pObjList, | 502 CPDF_IndirectObjectHolder* pObjList, |
| 503 FX_DWORD objnum, | 503 uint32_t objnum, |
| 504 FX_DWORD gennum) { | 504 uint32_t gennum) { |
| 505 CFX_AutoRestorer<int> restorer(&s_CurrentRecursionDepth); | 505 CFX_AutoRestorer<int> restorer(&s_CurrentRecursionDepth); |
| 506 if (++s_CurrentRecursionDepth > kParserMaxRecursionDepth) | 506 if (++s_CurrentRecursionDepth > kParserMaxRecursionDepth) |
| 507 return nullptr; | 507 return nullptr; |
| 508 | 508 |
| 509 FX_FILESIZE SavedPos = m_Pos; | 509 FX_FILESIZE SavedPos = m_Pos; |
| 510 bool bIsNumber; | 510 bool bIsNumber; |
| 511 CFX_ByteString word = GetNextWord(&bIsNumber); | 511 CFX_ByteString word = GetNextWord(&bIsNumber); |
| 512 if (word.GetLength() == 0) | 512 if (word.GetLength() == 0) |
| 513 return nullptr; | 513 return nullptr; |
| 514 | 514 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 if (byte1 == '\r' && byte2 == '\n') | 621 if (byte1 == '\r' && byte2 == '\n') |
| 622 return 2; | 622 return 2; |
| 623 | 623 |
| 624 if (byte1 == '\r' || byte1 == '\n') | 624 if (byte1 == '\r' || byte1 == '\n') |
| 625 return 1; | 625 return 1; |
| 626 | 626 |
| 627 return 0; | 627 return 0; |
| 628 } | 628 } |
| 629 | 629 |
| 630 CPDF_Stream* CPDF_SyntaxParser::ReadStream(CPDF_Dictionary* pDict, | 630 CPDF_Stream* CPDF_SyntaxParser::ReadStream(CPDF_Dictionary* pDict, |
| 631 FX_DWORD objnum, | 631 uint32_t objnum, |
| 632 FX_DWORD gennum) { | 632 uint32_t gennum) { |
| 633 CPDF_Object* pLenObj = pDict->GetElement("Length"); | 633 CPDF_Object* pLenObj = pDict->GetElement("Length"); |
| 634 FX_FILESIZE len = -1; | 634 FX_FILESIZE len = -1; |
| 635 CPDF_Reference* pLenObjRef = ToReference(pLenObj); | 635 CPDF_Reference* pLenObjRef = ToReference(pLenObj); |
| 636 | 636 |
| 637 bool differingObjNum = !pLenObjRef || (pLenObjRef->GetObjList() && | 637 bool differingObjNum = !pLenObjRef || (pLenObjRef->GetObjList() && |
| 638 pLenObjRef->GetRefObjNum() != objnum); | 638 pLenObjRef->GetRefObjNum() != objnum); |
| 639 if (pLenObj && differingObjNum) | 639 if (pLenObj && differingObjNum) |
| 640 len = pLenObj->GetInteger(); | 640 len = pLenObj->GetInteger(); |
| 641 | 641 |
| 642 // Locate the start of stream. | 642 // Locate the start of stream. |
| 643 ToNextLine(); | 643 ToNextLine(); |
| 644 FX_FILESIZE streamStartPos = m_Pos; | 644 FX_FILESIZE streamStartPos = m_Pos; |
| 645 | 645 |
| 646 const CFX_ByteStringC kEndStreamStr("endstream"); | 646 const CFX_ByteStringC kEndStreamStr("endstream"); |
| 647 const CFX_ByteStringC kEndObjStr("endobj"); | 647 const CFX_ByteStringC kEndObjStr("endobj"); |
| 648 | 648 |
| 649 IPDF_CryptoHandler* pCryptoHandler = | 649 IPDF_CryptoHandler* pCryptoHandler = |
| 650 objnum == (FX_DWORD)m_MetadataObjnum ? nullptr : m_pCryptoHandler.get(); | 650 objnum == (uint32_t)m_MetadataObjnum ? nullptr : m_pCryptoHandler.get(); |
| 651 if (!pCryptoHandler) { | 651 if (!pCryptoHandler) { |
| 652 FX_BOOL bSearchForKeyword = TRUE; | 652 FX_BOOL bSearchForKeyword = TRUE; |
| 653 if (len >= 0) { | 653 if (len >= 0) { |
| 654 pdfium::base::CheckedNumeric<FX_FILESIZE> pos = m_Pos; | 654 pdfium::base::CheckedNumeric<FX_FILESIZE> pos = m_Pos; |
| 655 pos += len; | 655 pos += len; |
| 656 if (pos.IsValid() && pos.ValueOrDie() < m_FileLen) | 656 if (pos.IsValid() && pos.ValueOrDie() < m_FileLen) |
| 657 m_Pos = pos.ValueOrDie(); | 657 m_Pos = pos.ValueOrDie(); |
| 658 | 658 |
| 659 m_Pos += ReadEOLMarkers(m_Pos); | 659 m_Pos += ReadEOLMarkers(m_Pos); |
| 660 FXSYS_memset(m_WordBuffer, 0, kEndStreamStr.GetLength() + 1); | 660 FXSYS_memset(m_WordBuffer, 0, kEndStreamStr.GetLength() + 1); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 if (m_WordSize == static_cast<unsigned int>(kEndObjStr.GetLength()) && | 775 if (m_WordSize == static_cast<unsigned int>(kEndObjStr.GetLength()) && |
| 776 numMarkers != 0 && | 776 numMarkers != 0 && |
| 777 FXSYS_memcmp(m_WordBuffer, kEndObjStr.GetPtr(), kEndObjStr.GetLength()) == | 777 FXSYS_memcmp(m_WordBuffer, kEndObjStr.GetPtr(), kEndObjStr.GetLength()) == |
| 778 0) { | 778 0) { |
| 779 m_Pos = streamStartPos; | 779 m_Pos = streamStartPos; |
| 780 } | 780 } |
| 781 return pStream; | 781 return pStream; |
| 782 } | 782 } |
| 783 | 783 |
| 784 void CPDF_SyntaxParser::InitParser(IFX_FileRead* pFileAccess, | 784 void CPDF_SyntaxParser::InitParser(IFX_FileRead* pFileAccess, |
| 785 FX_DWORD HeaderOffset) { | 785 uint32_t HeaderOffset) { |
| 786 FX_Free(m_pFileBuf); | 786 FX_Free(m_pFileBuf); |
| 787 | 787 |
| 788 m_pFileBuf = FX_Alloc(uint8_t, m_BufSize); | 788 m_pFileBuf = FX_Alloc(uint8_t, m_BufSize); |
| 789 m_HeaderOffset = HeaderOffset; | 789 m_HeaderOffset = HeaderOffset; |
| 790 m_FileLen = pFileAccess->GetSize(); | 790 m_FileLen = pFileAccess->GetSize(); |
| 791 m_Pos = 0; | 791 m_Pos = 0; |
| 792 m_pFileAccess = pFileAccess; | 792 m_pFileAccess = pFileAccess; |
| 793 m_BufOffset = 0; | 793 m_BufOffset = 0; |
| 794 pFileAccess->ReadBlock( | 794 pFileAccess->ReadBlock( |
| 795 m_pFileBuf, 0, | 795 m_pFileBuf, 0, |
| 796 (size_t)((FX_FILESIZE)m_BufSize > m_FileLen ? m_FileLen : m_BufSize)); | 796 (size_t)((FX_FILESIZE)m_BufSize > m_FileLen ? m_FileLen : m_BufSize)); |
| 797 } | 797 } |
| 798 | 798 |
| 799 uint32_t CPDF_SyntaxParser::GetDirectNum() { | 799 uint32_t CPDF_SyntaxParser::GetDirectNum() { |
| 800 bool bIsNumber; | 800 bool bIsNumber; |
| 801 GetNextWordInternal(&bIsNumber); | 801 GetNextWordInternal(&bIsNumber); |
| 802 if (!bIsNumber) | 802 if (!bIsNumber) |
| 803 return 0; | 803 return 0; |
| 804 | 804 |
| 805 m_WordBuffer[m_WordSize] = 0; | 805 m_WordBuffer[m_WordSize] = 0; |
| 806 return FXSYS_atoui(reinterpret_cast<const FX_CHAR*>(m_WordBuffer)); | 806 return FXSYS_atoui(reinterpret_cast<const FX_CHAR*>(m_WordBuffer)); |
| 807 } | 807 } |
| 808 | 808 |
| 809 bool CPDF_SyntaxParser::IsWholeWord(FX_FILESIZE startpos, | 809 bool CPDF_SyntaxParser::IsWholeWord(FX_FILESIZE startpos, |
| 810 FX_FILESIZE limit, | 810 FX_FILESIZE limit, |
| 811 const CFX_ByteStringC& tag, | 811 const CFX_ByteStringC& tag, |
| 812 FX_BOOL checkKeyword) { | 812 FX_BOOL checkKeyword) { |
| 813 const FX_DWORD taglen = tag.GetLength(); | 813 const uint32_t taglen = tag.GetLength(); |
| 814 | 814 |
| 815 bool bCheckLeft = !PDFCharIsDelimiter(tag[0]) && !PDFCharIsWhitespace(tag[0]); | 815 bool bCheckLeft = !PDFCharIsDelimiter(tag[0]) && !PDFCharIsWhitespace(tag[0]); |
| 816 bool bCheckRight = !PDFCharIsDelimiter(tag[taglen - 1]) && | 816 bool bCheckRight = !PDFCharIsDelimiter(tag[taglen - 1]) && |
| 817 !PDFCharIsWhitespace(tag[taglen - 1]); | 817 !PDFCharIsWhitespace(tag[taglen - 1]); |
| 818 | 818 |
| 819 uint8_t ch; | 819 uint8_t ch; |
| 820 if (bCheckRight && startpos + (int32_t)taglen <= limit && | 820 if (bCheckRight && startpos + (int32_t)taglen <= limit && |
| 821 GetCharAt(startpos + (int32_t)taglen, ch)) { | 821 GetCharAt(startpos + (int32_t)taglen, ch)) { |
| 822 if (PDFCharIsNumeric(ch) || PDFCharIsOther(ch) || | 822 if (PDFCharIsNumeric(ch) || PDFCharIsOther(ch) || |
| 823 (checkKeyword && PDFCharIsDelimiter(ch))) { | 823 (checkKeyword && PDFCharIsDelimiter(ch))) { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 int32_t CPDF_SyntaxParser::SearchMultiWord(const CFX_ByteStringC& tags, | 907 int32_t CPDF_SyntaxParser::SearchMultiWord(const CFX_ByteStringC& tags, |
| 908 FX_BOOL bWholeWord, | 908 FX_BOOL bWholeWord, |
| 909 FX_FILESIZE limit) { | 909 FX_FILESIZE limit) { |
| 910 int32_t ntags = 1; | 910 int32_t ntags = 1; |
| 911 for (int i = 0; i < tags.GetLength(); ++i) { | 911 for (int i = 0; i < tags.GetLength(); ++i) { |
| 912 if (tags[i] == 0) | 912 if (tags[i] == 0) |
| 913 ++ntags; | 913 ++ntags; |
| 914 } | 914 } |
| 915 | 915 |
| 916 std::vector<SearchTagRecord> patterns(ntags); | 916 std::vector<SearchTagRecord> patterns(ntags); |
| 917 FX_DWORD start = 0; | 917 uint32_t start = 0; |
| 918 FX_DWORD itag = 0; | 918 uint32_t itag = 0; |
| 919 FX_DWORD max_len = 0; | 919 uint32_t max_len = 0; |
| 920 for (int i = 0; i <= tags.GetLength(); ++i) { | 920 for (int i = 0; i <= tags.GetLength(); ++i) { |
| 921 if (tags[i] == 0) { | 921 if (tags[i] == 0) { |
| 922 FX_DWORD len = i - start; | 922 uint32_t len = i - start; |
| 923 max_len = std::max(len, max_len); | 923 max_len = std::max(len, max_len); |
| 924 patterns[itag].m_pTag = tags.GetCStr() + start; | 924 patterns[itag].m_pTag = tags.GetCStr() + start; |
| 925 patterns[itag].m_Len = len; | 925 patterns[itag].m_Len = len; |
| 926 patterns[itag].m_Offset = 0; | 926 patterns[itag].m_Offset = 0; |
| 927 start = i + 1; | 927 start = i + 1; |
| 928 ++itag; | 928 ++itag; |
| 929 } | 929 } |
| 930 } | 930 } |
| 931 | 931 |
| 932 const FX_FILESIZE pos_limit = m_Pos + limit; | 932 const FX_FILESIZE pos_limit = m_Pos + limit; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 981 if (limit && m_Pos == limit) | 981 if (limit && m_Pos == limit) |
| 982 return -1; | 982 return -1; |
| 983 } | 983 } |
| 984 return -1; | 984 return -1; |
| 985 } | 985 } |
| 986 | 986 |
| 987 void CPDF_SyntaxParser::SetEncrypt( | 987 void CPDF_SyntaxParser::SetEncrypt( |
| 988 std::unique_ptr<IPDF_CryptoHandler> pCryptoHandler) { | 988 std::unique_ptr<IPDF_CryptoHandler> pCryptoHandler) { |
| 989 m_pCryptoHandler = std::move(pCryptoHandler); | 989 m_pCryptoHandler = std::move(pCryptoHandler); |
| 990 } | 990 } |
| OLD | NEW |