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

Side by Side Diff: core/fxge/ge/fx_ge_text.cpp

Issue 1875673004: Fix integer issues leading to out of bounds access in fx_ge_text.cpp. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: whitespace nit Created 4 years, 8 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 | « no previous file | no next file » | 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 <limits>
8
7 #include "core/fxcodec/include/fx_codec.h" 9 #include "core/fxcodec/include/fx_codec.h"
8 #include "core/fxge/ge/fx_text_int.h" 10 #include "core/fxge/ge/fx_text_int.h"
9 #include "core/fxge/include/fx_freetype.h" 11 #include "core/fxge/include/fx_freetype.h"
10 #include "core/fxge/include/fx_ge.h" 12 #include "core/fxge/include/fx_ge.h"
11 13
12 #ifdef _SKIA_SUPPORT_ 14 #ifdef _SKIA_SUPPORT_
13 #include "third_party/skia/include/core/SkStream.h" 15 #include "third_party/skia/include/core/SkStream.h"
14 #include "third_party/skia/include/core/SkTypeface.h" 16 #include "third_party/skia/include/core/SkTypeface.h"
15 #endif 17 #endif
16 18
(...skipping 1544 matching lines...) Expand 10 before | Expand all | Expand 10 after
1561 if (pSubstFont) { 1563 if (pSubstFont) {
1562 bUseCJKSubFont = pSubstFont->m_bSubstOfCJK && bFontStyle; 1564 bUseCJKSubFont = pSubstFont->m_bSubstOfCJK && bFontStyle;
1563 int skew = 0; 1565 int skew = 0;
1564 if (bUseCJKSubFont) { 1566 if (bUseCJKSubFont) {
1565 skew = pSubstFont->m_bItlicCJK ? -15 : 0; 1567 skew = pSubstFont->m_bItlicCJK ? -15 : 0;
1566 } else { 1568 } else {
1567 skew = pSubstFont->m_ItalicAngle; 1569 skew = pSubstFont->m_ItalicAngle;
1568 } 1570 }
1569 if (skew) { 1571 if (skew) {
1570 // skew is nonpositive so -skew is used as the index. 1572 // skew is nonpositive so -skew is used as the index.
1571 skew = -skew <= static_cast<int>(ANGLESKEW_ARRAY_SIZE) 1573 if (skew < 0 && skew != std::numeric_limits<int>::min() &&
1572 ? -58 1574 static_cast<size_t>(-skew) < ANGLESKEW_ARRAY_SIZE) {
Wei Li 2016/04/11 16:40:37 /skew < 0/skew <= 0/ Also, casting to size_t make
Oliver Chang 2016/04/11 16:51:42 Done.
1573 : -g_AngleSkew[-skew]; 1575 skew = -g_AngleSkew[-skew];
1576 } else {
1577 skew = -58;
1578 }
1574 if (pFont->IsVertical()) 1579 if (pFont->IsVertical())
1575 ft_matrix.yx += ft_matrix.yy * skew / 100; 1580 ft_matrix.yx += ft_matrix.yy * skew / 100;
1576 else 1581 else
1577 ft_matrix.xy += -ft_matrix.xx * skew / 100; 1582 ft_matrix.xy += -ft_matrix.xx * skew / 100;
1578 } 1583 }
1579 if (pSubstFont->m_SubstFlags & FXFONT_SUBST_MM) { 1584 if (pSubstFont->m_SubstFlags & FXFONT_SUBST_MM) {
1580 pFont->AdjustMMParams(glyph_index, dest_width, 1585 pFont->AdjustMMParams(glyph_index, dest_width,
1581 pFont->GetSubstFont()->m_Weight); 1586 pFont->GetSubstFont()->m_Weight);
1582 } 1587 }
1583 } 1588 }
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
1827 CFX_PathData* CFX_Font::LoadGlyphPath(uint32_t glyph_index, int dest_width) { 1832 CFX_PathData* CFX_Font::LoadGlyphPath(uint32_t glyph_index, int dest_width) {
1828 if (!m_Face) { 1833 if (!m_Face) {
1829 return NULL; 1834 return NULL;
1830 } 1835 }
1831 FXFT_Set_Pixel_Sizes(m_Face, 0, 64); 1836 FXFT_Set_Pixel_Sizes(m_Face, 0, 64);
1832 FXFT_Matrix ft_matrix = {65536, 0, 0, 65536}; 1837 FXFT_Matrix ft_matrix = {65536, 0, 0, 65536};
1833 if (m_pSubstFont) { 1838 if (m_pSubstFont) {
1834 if (m_pSubstFont->m_ItalicAngle) { 1839 if (m_pSubstFont->m_ItalicAngle) {
1835 int skew = m_pSubstFont->m_ItalicAngle; 1840 int skew = m_pSubstFont->m_ItalicAngle;
1836 // skew is nonpositive so -skew is used as the index. 1841 // skew is nonpositive so -skew is used as the index.
1837 skew = -skew <= static_cast<int>(ANGLESKEW_ARRAY_SIZE) 1842 if (skew < 0 && skew != std::numeric_limits<int>::min() &&
Wei Li 2016/04/11 17:00:47 skew <= 0 here too. Since you are here, can you p
Oliver Chang 2016/04/11 17:06:47 Already made this <= 0 too. Added the comment
1838 ? -58 1843 static_cast<size_t>(-skew) < ANGLESKEW_ARRAY_SIZE) {
1839 : -g_AngleSkew[-skew]; 1844 skew = -g_AngleSkew[-skew];
1845 } else {
1846 skew = -58;
1847 }
1840 if (m_bVertical) 1848 if (m_bVertical)
1841 ft_matrix.yx += ft_matrix.yy * skew / 100; 1849 ft_matrix.yx += ft_matrix.yy * skew / 100;
1842 else 1850 else
1843 ft_matrix.xy += -ft_matrix.xx * skew / 100; 1851 ft_matrix.xy += -ft_matrix.xx * skew / 100;
1844 } 1852 }
1845 if (m_pSubstFont->m_SubstFlags & FXFONT_SUBST_MM) { 1853 if (m_pSubstFont->m_SubstFlags & FXFONT_SUBST_MM) {
1846 AdjustMMParams(glyph_index, dest_width, m_pSubstFont->m_Weight); 1854 AdjustMMParams(glyph_index, dest_width, m_pSubstFont->m_Weight);
1847 } 1855 }
1848 } 1856 }
1849 ScopedFontTransform scoped_transform(m_Face, &ft_matrix); 1857 ScopedFontTransform scoped_transform(m_Face, &ft_matrix);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1897 void _CFX_UniqueKeyGen::Generate(int count, ...) { 1905 void _CFX_UniqueKeyGen::Generate(int count, ...) {
1898 va_list argList; 1906 va_list argList;
1899 va_start(argList, count); 1907 va_start(argList, count);
1900 for (int i = 0; i < count; i++) { 1908 for (int i = 0; i < count; i++) {
1901 int p = va_arg(argList, int); 1909 int p = va_arg(argList, int);
1902 ((uint32_t*)m_Key)[i] = p; 1910 ((uint32_t*)m_Key)[i] = p;
1903 } 1911 }
1904 va_end(argList); 1912 va_end(argList);
1905 m_KeyLen = count * sizeof(uint32_t); 1913 m_KeyLen = count * sizeof(uint32_t);
1906 } 1914 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698