mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-23 07:51:10 +01:00
[glyf] Restore scratch length when gvar fails in get_points; clear comp_points at entry
Glyph::get_points() uses scratch.comp_points as a stack shared by all recursion levels: it appends one point per component plus four phantoms, and every exit restores points.length to old_length -- except the exit taken when gvar->apply_deltas_to_points() returns false (for example on a tuple whose variationDataSize overruns its data). Because the hb_glyf_scratch_t is cached on the glyf (and VARC) accelerator for the life of the face, every failed depth-0 load grows the vector permanently, until it reaches its allocation ceiling; a VARC font can drive hundreds of thousands of such failing leaf loads within one glyph budget, leaving tens of megabytes behind per extents or draw call. Balance the missing exit the way every sibling exit (and #6410) already does. Also clear comp_points next to the existing all_points.clear() at the depth-0 entry in glyf_accelerator_t::get_points(), the only entry into the cached scratch (the subsetter's call uses a local scratch), so the cached vector can never carry stale points across loads even if a future exit forgets the discipline. No behaviour change for well-formed fonts: the resize only runs on the failure path and comp_points is empty at entry when exits are balanced. Adds a minimized VARC+gvar font to test/fuzzing/fonts exercising the failing path through the shape/draw/raster/vector/subset fuzzers. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-NM4GCMBX. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
c5d3fdda16
commit
220ef2ca34
3 files changed
+6
No files matched your search
@@ -423,7 +423,10 @@ struct Glyph
|
||||
gvar_cache,
|
||||
phantom_only && type == SIMPLE,
|
||||
budget))
|
||||
{
|
||||
points.resize (old_length);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -297,6 +297,9 @@ struct glyf_accelerator_t
|
||||
|
||||
auto &all_points = scratch.all_points;
|
||||
all_points.clear ();
|
||||
/* The scratch is cached across loads; don't let a failed one leave
|
||||
* component points behind. */
|
||||
scratch.comp_points.clear ();
|
||||
|
||||
bool phantom_only = !consumer.is_consuming_contour_points ();
|
||||
if (unlikely (!glyph_for_gid (gid).get_points (font, *this, all_points, scratch, nullptr, nullptr, nullptr, true, true, phantom_only, coords, gvar_cache, 0, nullptr, budget)))
|
||||
|
||||
Binary file not shown.
Reference in new issue
Block a user