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

Side by Side Diff: core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp

Issue 1499433002: fix for stream object reading (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « no previous file | testing/resources/pixel/bug_551258_1.in » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 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 "parser_int.h" 7 #include "parser_int.h"
8 8
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 2334 matching lines...) Expand 10 before | Expand all | Expand 10 after
2345 FX_BOOL bSearchForKeyword = TRUE; 2345 FX_BOOL bSearchForKeyword = TRUE;
2346 if (len >= 0) { 2346 if (len >= 0) {
2347 pdfium::base::CheckedNumeric<FX_FILESIZE> pos = m_Pos; 2347 pdfium::base::CheckedNumeric<FX_FILESIZE> pos = m_Pos;
2348 pos += len; 2348 pos += len;
2349 if (pos.IsValid() && pos.ValueOrDie() < m_FileLen) { 2349 if (pos.IsValid() && pos.ValueOrDie() < m_FileLen) {
2350 m_Pos = pos.ValueOrDie(); 2350 m_Pos = pos.ValueOrDie();
2351 } 2351 }
2352 m_Pos += ReadEOLMarkers(m_Pos); 2352 m_Pos += ReadEOLMarkers(m_Pos);
2353 FXSYS_memset(m_WordBuffer, 0, ENDSTREAM_LEN + 1); 2353 FXSYS_memset(m_WordBuffer, 0, ENDSTREAM_LEN + 1);
2354 GetNextWord(); 2354 GetNextWord();
2355 if (FXSYS_memcmp(m_WordBuffer, "endstream", ENDSTREAM_LEN) == 0 && 2355 // Earlier version of PDF specification doesn't require EOL marker before
2356 IsWholeWord(m_Pos - ENDSTREAM_LEN, m_FileLen, 2356 // 'endstream' keyword. If keyword 'endstream' follows the bytes in
2357 FX_BSTRC("endstream").GetPtr(), ENDSTREAM_LEN, TRUE)) { 2357 // specified length, it signals the end of stream.
2358 if (FXSYS_memcmp(m_WordBuffer, "endstream", ENDSTREAM_LEN) == 0)
2358 bSearchForKeyword = FALSE; 2359 bSearchForKeyword = FALSE;
2359 }
2360 } 2360 }
2361 if (bSearchForKeyword) { 2361 if (bSearchForKeyword) {
2362 // If len is not available, len needs to be calculated 2362 // If len is not available, len needs to be calculated
2363 // by searching the keywords "endstream" or "endobj". 2363 // by searching the keywords "endstream" or "endobj".
2364 m_Pos = streamStartPos; 2364 m_Pos = streamStartPos;
2365 FX_FILESIZE endStreamOffset = 0; 2365 FX_FILESIZE endStreamOffset = 0;
2366 while (endStreamOffset >= 0) { 2366 while (endStreamOffset >= 0) {
2367 endStreamOffset = FindTag(FX_BSTRC("endstream"), 0); 2367 endStreamOffset = FindTag(FX_BSTRC("endstream"), 0);
2368 if (endStreamOffset < 0) { 2368 if (endStreamOffset < 0) {
2369 // Can't find any "endstream". 2369 // Can't find any "endstream".
(...skipping 2571 matching lines...) Expand 10 before | Expand all | Expand 10 after
4941 if (!m_pLinearizedDict) 4941 if (!m_pLinearizedDict)
4942 return -1; 4942 return -1;
4943 CPDF_Array* pRange = m_pLinearizedDict->GetArray(FX_BSTRC("H")); 4943 CPDF_Array* pRange = m_pLinearizedDict->GetArray(FX_BSTRC("H"));
4944 if (!pRange) 4944 if (!pRange)
4945 return -1; 4945 return -1;
4946 CPDF_Object* pStreamLen = pRange->GetElementValue(1); 4946 CPDF_Object* pStreamLen = pRange->GetElementValue(1);
4947 if (!pStreamLen) 4947 if (!pStreamLen)
4948 return -1; 4948 return -1;
4949 return pStreamLen->GetInteger(); 4949 return pStreamLen->GetInteger();
4950 } 4950 }
OLDNEW
« no previous file with comments | « no previous file | testing/resources/pixel/bug_551258_1.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698