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

Side by Side Diff: core/fpdfapi/parser/cpdf_syntax_parser.cpp

Issue 2430743003: in the attempt to fix 627393, changed IFX_FileRead's readBlock to return the length it reads
Patch Set: fix an undefined variable 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 unified diff | Download patch
OLDNEW
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/parser/cpdf_syntax_parser.h" 7 #include "core/fpdfapi/parser/cpdf_syntax_parser.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 bool CPDF_SyntaxParser::ReadChar(FX_FILESIZE read_pos, uint32_t read_size) { 58 bool CPDF_SyntaxParser::ReadChar(FX_FILESIZE read_pos, uint32_t read_size) {
59 if (static_cast<FX_FILESIZE>(read_pos + read_size) > m_FileLen) { 59 if (static_cast<FX_FILESIZE>(read_pos + read_size) > m_FileLen) {
60 if (m_FileLen < static_cast<FX_FILESIZE>(read_size)) { 60 if (m_FileLen < static_cast<FX_FILESIZE>(read_size)) {
61 read_pos = 0; 61 read_pos = 0;
62 read_size = static_cast<uint32_t>(m_FileLen); 62 read_size = static_cast<uint32_t>(m_FileLen);
63 } else { 63 } else {
64 read_pos = m_FileLen - read_size; 64 read_pos = m_FileLen - read_size;
65 } 65 }
66 } 66 }
67 if (!m_pFileAccess->ReadBlock(m_pFileBuf, read_pos, read_size)) 67 if (m_pFileAccess->ReadBlock(m_pFileBuf, read_pos, read_size) != read_size &&
68 !m_pFileAccess->IsEOF())
68 return false; 69 return false;
69 70
70 m_BufOffset = read_pos; 71 m_BufOffset = read_pos;
71 return true; 72 return true;
72 } 73 }
73 74
74 bool CPDF_SyntaxParser::GetNextChar(uint8_t& ch) { 75 bool CPDF_SyntaxParser::GetNextChar(uint8_t& ch) {
75 FX_FILESIZE pos = m_Pos + m_HeaderOffset; 76 FX_FILESIZE pos = m_Pos + m_HeaderOffset;
76 if (pos >= m_FileLen) 77 if (pos >= m_FileLen)
77 return false; 78 return false;
(...skipping 23 matching lines...) Expand all
101 read_pos = pos - m_BufSize + 1; 102 read_pos = pos - m_BufSize + 1;
102 uint32_t read_size = m_BufSize; 103 uint32_t read_size = m_BufSize;
103 if (!ReadChar(read_pos, read_size)) 104 if (!ReadChar(read_pos, read_size))
104 return false; 105 return false;
105 } 106 }
106 ch = m_pFileBuf[pos - m_BufOffset]; 107 ch = m_pFileBuf[pos - m_BufOffset];
107 return true; 108 return true;
108 } 109 }
109 110
110 bool CPDF_SyntaxParser::ReadBlock(uint8_t* pBuf, uint32_t size) { 111 bool CPDF_SyntaxParser::ReadBlock(uint8_t* pBuf, uint32_t size) {
111 if (!m_pFileAccess->ReadBlock(pBuf, m_Pos + m_HeaderOffset, size)) 112 uint32_t readSize =
113 m_pFileAccess->ReadBlock(pBuf, m_Pos + m_HeaderOffset, size);
114 if (readSize != size && !m_pFileAccess->IsEOF())
112 return false; 115 return false;
113 m_Pos += size; 116 m_Pos += readSize;
114 return true; 117 return true;
115 } 118 }
116 119
117 void CPDF_SyntaxParser::GetNextWordInternal(bool* bIsNumber) { 120 void CPDF_SyntaxParser::GetNextWordInternal(bool* bIsNumber) {
118 m_WordSize = 0; 121 m_WordSize = 0;
119 if (bIsNumber) 122 if (bIsNumber)
120 *bIsNumber = true; 123 *bIsNumber = true;
121 124
122 uint8_t ch; 125 uint8_t ch;
123 if (!GetNextChar(ch)) 126 if (!GetNextChar(ch))
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 } 916 }
914 917
915 void CPDF_SyntaxParser::SetEncrypt( 918 void CPDF_SyntaxParser::SetEncrypt(
916 std::unique_ptr<CPDF_CryptoHandler> pCryptoHandler) { 919 std::unique_ptr<CPDF_CryptoHandler> pCryptoHandler) {
917 m_pCryptoHandler = std::move(pCryptoHandler); 920 m_pCryptoHandler = std::move(pCryptoHandler);
918 } 921 }
919 922
920 CFX_ByteString CPDF_SyntaxParser::MaybeIntern(const CFX_ByteString& str) { 923 CFX_ByteString CPDF_SyntaxParser::MaybeIntern(const CFX_ByteString& str) {
921 return m_pPool ? m_pPool->Intern(str) : str; 924 return m_pPool ? m_pPool->Intern(str) : str;
922 } 925 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698