Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/glyph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ bool ReadGlyph(const uint8_t* data, size_t len, Glyph* glyph) {
if (!buffer.ReadU16(&point_index)) {
return FONT_COMPRESSION_FAILURE();
}
// endPtsOfContours must be monotonically increasing per the TrueType
// spec. A decreasing value wraps the uint16 subtraction below, causing
// huge allocations from small inputs (memory-amplification DoS).
if (i > 0 && point_index < last_point_index) {
return FONT_COMPRESSION_FAILURE();
}
uint16_t num_points = point_index - last_point_index + (i == 0 ? 1 : 0);
glyph->contours[i].resize(num_points);
last_point_index = point_index;
Expand Down