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

Side by Side Diff: core/fpdfapi/fpdf_page/fpdf_page_parser.cpp

Issue 2095763003: Improve hint table validation checks. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 4 years, 5 months 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 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 "core/fpdfapi/fpdf_page/pageint.h" 7 #include "core/fpdfapi/fpdf_page/pageint.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 int index = m_ParamStartPos + m_ParamCount; 267 int index = m_ParamStartPos + m_ParamCount;
268 if (index >= PARAM_BUF_SIZE) { 268 if (index >= PARAM_BUF_SIZE) {
269 index -= PARAM_BUF_SIZE; 269 index -= PARAM_BUF_SIZE;
270 } 270 }
271 m_ParamCount++; 271 m_ParamCount++;
272 return index; 272 return index;
273 } 273 }
274 274
275 void CPDF_StreamContentParser::AddNameParam(const FX_CHAR* name, int len) { 275 void CPDF_StreamContentParser::AddNameParam(const FX_CHAR* name, int len) {
276 CFX_ByteStringC bsName(name, len); 276 CFX_ByteStringC bsName(name, len);
277 int index = GetNextParamPos(); 277 ContentParam& param = m_ParamBuf[GetNextParamPos()];
278 if (len > 32) { 278 if (len > 32) {
279 m_ParamBuf[index].m_Type = ContentParam::OBJECT; 279 param.m_Type = ContentParam::OBJECT;
280 m_ParamBuf[index].m_pObject = new CPDF_Name(PDF_NameDecode(bsName)); 280 param.m_pObject = new CPDF_Name(PDF_NameDecode(bsName));
281 } else { 281 } else {
282 m_ParamBuf[index].m_Type = ContentParam::NAME; 282 param.m_Type = ContentParam::NAME;
283 if (bsName.Find('#') == -1) { 283 if (bsName.Find('#') == -1) {
284 FXSYS_memcpy(m_ParamBuf[index].m_Name.m_Buffer, name, len); 284 FXSYS_memcpy(param.m_Name.m_Buffer, name, len);
285 m_ParamBuf[index].m_Name.m_Len = len; 285 param.m_Name.m_Len = len;
286 } else { 286 } else {
287 CFX_ByteString str = PDF_NameDecode(bsName); 287 CFX_ByteString str = PDF_NameDecode(bsName);
288 FXSYS_memcpy(m_ParamBuf[index].m_Name.m_Buffer, str.c_str(), 288 FXSYS_memcpy(param.m_Name.m_Buffer, str.c_str(), str.GetLength());
289 str.GetLength()); 289 param.m_Name.m_Len = str.GetLength();
290 m_ParamBuf[index].m_Name.m_Len = str.GetLength();
291 } 290 }
292 } 291 }
293 } 292 }
294 293
295 void CPDF_StreamContentParser::AddNumberParam(const FX_CHAR* str, int len) { 294 void CPDF_StreamContentParser::AddNumberParam(const FX_CHAR* str, int len) {
296 int index = GetNextParamPos(); 295 ContentParam& param = m_ParamBuf[GetNextParamPos()];
297 m_ParamBuf[index].m_Type = ContentParam::NUMBER; 296 param.m_Type = ContentParam::NUMBER;
298 FX_atonum(CFX_ByteStringC(str, len), m_ParamBuf[index].m_Number.m_bInteger, 297 param.m_Number.m_bInteger =
299 &m_ParamBuf[index].m_Number.m_Integer); 298 FX_atonum(CFX_ByteStringC(str, len), &param.m_Number.m_Integer);
300 } 299 }
300
301 void CPDF_StreamContentParser::AddObjectParam(CPDF_Object* pObj) { 301 void CPDF_StreamContentParser::AddObjectParam(CPDF_Object* pObj) {
302 int index = GetNextParamPos(); 302 ContentParam& param = m_ParamBuf[GetNextParamPos()];
303 m_ParamBuf[index].m_Type = ContentParam::OBJECT; 303 param.m_Type = ContentParam::OBJECT;
304 m_ParamBuf[index].m_pObject = pObj; 304 param.m_pObject = pObj;
305 } 305 }
306
306 void CPDF_StreamContentParser::ClearAllParams() { 307 void CPDF_StreamContentParser::ClearAllParams() {
307 uint32_t index = m_ParamStartPos; 308 uint32_t index = m_ParamStartPos;
308 for (uint32_t i = 0; i < m_ParamCount; i++) { 309 for (uint32_t i = 0; i < m_ParamCount; i++) {
309 if (m_ParamBuf[index].m_Type == 0) { 310 if (m_ParamBuf[index].m_Type == 0) {
310 if (CPDF_Object* pObject = m_ParamBuf[index].m_pObject) 311 if (CPDF_Object* pObject = m_ParamBuf[index].m_pObject)
311 pObject->Release(); 312 pObject->Release();
312 } 313 }
313 index++; 314 index++;
314 if (index == PARAM_BUF_SIZE) { 315 if (index == PARAM_BUF_SIZE) {
315 index = 0; 316 index = 0;
(...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1594 } 1595 }
1595 } else { 1596 } else {
1596 bProcessed = FALSE; 1597 bProcessed = FALSE;
1597 } 1598 }
1598 if (bProcessed) { 1599 if (bProcessed) {
1599 last_pos = m_pSyntax->GetPos(); 1600 last_pos = m_pSyntax->GetPos();
1600 } 1601 }
1601 break; 1602 break;
1602 } 1603 }
1603 case CPDF_StreamParser::Number: { 1604 case CPDF_StreamParser::Number: {
1604 if (nParams == 6) { 1605 if (nParams == 6)
1605 break; 1606 break;
1606 } 1607
1607 FX_BOOL bInteger;
1608 int value; 1608 int value;
1609 FX_atonum( 1609 bool bInteger = FX_atonum(
1610 CFX_ByteStringC(m_pSyntax->GetWordBuf(), m_pSyntax->GetWordSize()), 1610 CFX_ByteStringC(m_pSyntax->GetWordBuf(), m_pSyntax->GetWordSize()),
1611 bInteger, &value); 1611 &value);
1612 params[nParams++] = bInteger ? (FX_FLOAT)value : *(FX_FLOAT*)&value; 1612 params[nParams++] = bInteger ? (FX_FLOAT)value : *(FX_FLOAT*)&value;
1613 break; 1613 break;
1614 } 1614 }
1615 default: 1615 default:
1616 bProcessed = FALSE; 1616 bProcessed = FALSE;
1617 } 1617 }
1618 if (!bProcessed) { 1618 if (!bProcessed) {
1619 m_pSyntax->SetPos(last_pos); 1619 m_pSyntax->SetPos(last_pos);
1620 return; 1620 return;
1621 } 1621 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1681 } else { 1681 } else {
1682 PDF_ReplaceAbbr(pElement); 1682 PDF_ReplaceAbbr(pElement);
1683 } 1683 }
1684 } 1684 }
1685 break; 1685 break;
1686 } 1686 }
1687 default: 1687 default:
1688 break; 1688 break;
1689 } 1689 }
1690 } 1690 }
OLDNEW
« no previous file with comments | « no previous file | core/fpdfapi/fpdf_page/pageint.h » ('j') | core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698