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

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

Issue 1710403002: Use safe arithmentic in CFX_BinaryBuf::ExpandBuf. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: needless uint8_t casts. Created 4 years, 10 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
« no previous file with comments | « core/include/fxcrt/fx_safe_types.h ('k') | core/src/fxcodec/codec/fx_codec_fax.cpp » ('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 "core/include/fpdfapi/fpdf_parser.h" 7 #include "core/include/fpdfapi/fpdf_parser.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 1855 matching lines...) Expand 10 before | Expand all | Expand 10 after
1866 } 1866 }
1867 } 1867 }
1868 GetNextChar(ch); 1868 GetNextChar(ch);
1869 return buf.GetByteString(); 1869 return buf.GetByteString();
1870 } 1870 }
1871 CFX_ByteString CPDF_SyntaxParser::ReadHexString() { 1871 CFX_ByteString CPDF_SyntaxParser::ReadHexString() {
1872 uint8_t ch; 1872 uint8_t ch;
1873 if (!GetNextChar(ch)) 1873 if (!GetNextChar(ch))
1874 return CFX_ByteString(); 1874 return CFX_ByteString();
1875 1875
1876 CFX_BinaryBuf buf; 1876 CFX_ByteTextBuf buf;
1877 bool bFirst = true; 1877 bool bFirst = true;
1878 uint8_t code = 0; 1878 uint8_t code = 0;
1879 while (1) { 1879 while (1) {
1880 if (ch == '>') 1880 if (ch == '>')
1881 break; 1881 break;
1882 1882
1883 if (std::isxdigit(ch)) { 1883 if (std::isxdigit(ch)) {
1884 int val = FXSYS_toHexDigit(ch); 1884 int val = FXSYS_toHexDigit(ch);
1885 if (bFirst) { 1885 if (bFirst) {
1886 code = val * 16; 1886 code = val * 16;
1887 } else { 1887 } else {
1888 code += val; 1888 code += val;
1889 buf.AppendByte((uint8_t)code); 1889 buf.AppendByte(code);
1890 } 1890 }
1891 bFirst = !bFirst; 1891 bFirst = !bFirst;
1892 } 1892 }
1893 1893
1894 if (!GetNextChar(ch)) 1894 if (!GetNextChar(ch))
1895 break; 1895 break;
1896 } 1896 }
1897 if (!bFirst) 1897 if (!bFirst)
1898 buf.AppendByte((uint8_t)code); 1898 buf.AppendByte(code);
1899 1899
1900 return buf.GetByteString(); 1900 return buf.GetByteString();
1901 } 1901 }
1902 void CPDF_SyntaxParser::ToNextLine() { 1902 void CPDF_SyntaxParser::ToNextLine() {
1903 uint8_t ch; 1903 uint8_t ch;
1904 while (GetNextChar(ch)) { 1904 while (GetNextChar(ch)) {
1905 if (ch == '\n') { 1905 if (ch == '\n') {
1906 break; 1906 break;
1907 } 1907 }
1908 if (ch == '\r') { 1908 if (ch == '\r') {
(...skipping 2831 matching lines...) Expand 10 before | Expand all | Expand 10 after
4740 if (!m_pLinearizedDict) 4740 if (!m_pLinearizedDict)
4741 return -1; 4741 return -1;
4742 CPDF_Array* pRange = m_pLinearizedDict->GetArrayBy("H"); 4742 CPDF_Array* pRange = m_pLinearizedDict->GetArrayBy("H");
4743 if (!pRange) 4743 if (!pRange)
4744 return -1; 4744 return -1;
4745 CPDF_Object* pStreamLen = pRange->GetElementValue(1); 4745 CPDF_Object* pStreamLen = pRange->GetElementValue(1);
4746 if (!pStreamLen) 4746 if (!pStreamLen)
4747 return -1; 4747 return -1;
4748 return pStreamLen->GetInteger(); 4748 return pStreamLen->GetInteger();
4749 } 4749 }
OLDNEW
« no previous file with comments | « core/include/fxcrt/fx_safe_types.h ('k') | core/src/fxcodec/codec/fx_codec_fax.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698