Commit Graph
249 Commits
Author SHA1 Message Date
Behdad Esfahbod 5cb6cac5f7 Merge pull request #6505 from harfbuzz/scanner/repacker
[repacker] Fix an OOB write, an overflow-error crash, and six repacker DoS issues
2026-11-02 11:48:40 -06:00
Behdad Esfahbod 07c411aff4 [repacker] Check visited vector resize result (#6541)
update_distances() checked the vector's error state after resize(), but
left the return value unchecked, triggering Coverity CID 506917.

Check resize() directly and return ALLOCATION_FAILURE on failure. This
preserves the existing allocation failure behavior.

Tested with meson compile -C build -j 6 and meson test -C build
(275 tests passed).

Assisted-by: OpenAI Codex
2026-11-01 13:52:56 -07:00
Behdad EsfahbodandClaude Opus 4.8 636e97026e [repacker] Split PairPos and MarkArray subtables in linear time
When the repacker splits an oversized GPOS subtable, the splitters
resolved and re-homed the subtable's links one at a time with
graph_t::index_for_offset() and graph_t::move_child(), each of which
scans the vertex's link list from the start, so a split was quadratic
in the number of links and no repacker limit counted that work.  A
crafted 131 KB font with 20 PairPosFormat1 subtables of 65,534 PairSets
took ~45 s of CPU in hb-subset.

Use the graph's existing tools the way ligature-graph.hh already does:

- PairPosFormat1::split_subtables() builds position_to_index_map() once
  and looks each PairSet up in it; clone_range() sorts the links by
  position and moves the whole [start, end) offset range with one
  move_children() call, which keeps the moved and remaining links in
  order.
- PairPosFormat2::clone_class1_records() now moves the class1 record
  byte range (whose only links are device tables) with one
  move_children() call, folding in the former transfer_device_tables()
  and dropping its move_child()-per-value-record loop and the re-sort
  of the whole link list after each record.
- MarkArray::clone() adds the new mark-anchor links directly and
  removes the old ones in a single pass, the pattern
  AnchorMatrix::clone_rows() already uses.

The now-unused pair_set_graph_index() helper and split_context_t
fields are dropped.  The reproducer drops to ~1.5 s; a new test,
test_resolve_with_shared_pair_set_pair_pos_1_split, checks the split
keeps PairSets in order; no public API/ABI change.

Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-PQL6ZZ89.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-30 15:46:23 -06:00
Behdad EsfahbodandClaude Opus 4.8 c9a8620c00 [graph] Keep the Coverage range count of class_def_size_estimator_t incremental
add_class_def_size() rebuilt the Coverage size estimate by walking
every range of included_glyphs (num_glyph_ranges()) each time a class
added a glyph, so PairPosFormat2::split_subtables() did O(classes^2)
next_range() calls per subtable; a 131 KB font with 65535 single-glyph
classes numbered out of glyph order took minutes in hb_subset_or_fail().
The ClassDef half of the estimator was already made incremental in
19de83dad and #6212 skips the recount when a class adds no glyph, but
every class that does add a glyph still triggered a full recount.

Do the same for the Coverage half: a coverage_range_count member
(zeroed in reset()) is updated from the ranges of the newly added
class alone, adding one per range and subtracting one for each already
included neighbour (start-1, end+1) it merges with.  This is exact
because every glyph belongs to exactly one class, so the new glyphs are
never already included; the population-unchanged shortcut therefore
becomes redundant and num_glyph_ranges() is removed.

A regression test is added to test-classdef-graph.cc whose classes
extend and bridge already-included ranges.  Output is byte-identical;
the 8-subtable reproducer drops from >100 s to ~1 s; no public API/ABI
change.

This is the Coverage-estimation half left open by PR #6212.

Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-ZUWZMWMD.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-30 15:37:38 -06:00
Behdad EsfahbodandClaude Opus 4.8 95086deff1 [repacker] Count wide parents of all space roots in one pass
isolate_subgraph() called wide_parents() once per 32-bit space root,
and each call walked the complete real_links list of every parent of
that root, so a parent with M wide links to M roots (a
FeatureVariations ConditionSet with thousands of Offset32s) was walked
M times: N*M^2 work that no repacker limit bounds.  A crafted 223 KB
font with 150 overlapping ConditionSets kept hb-subset busy ~45-60 s.

wide_parents() now takes the whole roots set and the subgraph count
map: it seeds every root with count 0, collects the union of the
roots' parents, then walks each parent's links once, incrementing the
count of any root a wide unsigned link targets.  The per-root counts
and the 'parents' set are identical to before, so the subsets emitted
are byte-identical; only the work drops to the sum of the parents'
link counts.  wide_parents() is private to graph_t with no other
callers.

A regression test, test_isolate_subgraph_shared_wide_parents(), builds
the shared-wide-parent shape and checks isolate_subgraph() duplicates
exactly the one leaf with an outside 16-bit edge.  The attack font
drops to ~1.1 s; no public API/ABI change.

Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-8FR2M4SS.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-30 15:37:38 -06:00
Behdad EsfahbodandClaude Opus 4.8 7e28f358ae [repacker] De-duplicate overflow records without an overflow_record_t hash map
will_overflow() de-duplicated (parent, child) overflow records through
an hb_hashmap_t keyed by overflow_record_t, whose hash() collapses to
2654435761 * (31 * parent + child).  With dense vertex ids, a graph
where many consecutive vertices link the same children puts all records
into a handful of equal-hash chains, so the map degenerates into
quadratic probing and repeated over-growth in every resolution round: a
crafted 60 KB GDEF font with a LigCaretList of overlapping LigGlyphs
took ~65 s of CPU and ~520 MiB before failing.

graph.ordering_ is a permutation of the vertices, so every parent is
visited exactly once and a duplicate record can only come from two
links of the same parent to the same child.  A per-parent hb_set_t of
the children already recorded, cleared when moving to the next parent,
yields exactly the same records in the same order with no hashing of
records at all.  The now-unused operator==/!=/hash() on
overflow_record_t are removed (the struct is only used in vectors
elsewhere).

A regression test, test_will_overflow_records(), asserts one record per
overflowing (parent, child) pair when a parent links the same child
twice.  The attack font drops to ~1.3 s CPU and 133 MiB, the remaining
cost being the 1.8 million links the sanitizer budget admits; no public
API/ABI change.

Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-QNM0BP56.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-30 15:37:38 -06:00
Behdad EsfahbodandClaude Opus 4.8 9179b64235 [repacker] Propagate the vertex limit error during overflow resolution
HB_REPACKER_MAX_VERTICES is enforced inside graph_t::duplicate() by
returning LIMIT_EXCEEDED, but since the hb_result_t conversion the two
callers that drive overflow resolution threw that error away:
duplicate_subgraph() recorded it in a local and returned Ok, and
_resolve_shared_overflow() mapped every error to Ok(false) ("couldn't
duplicate, try something else").  hb_resolve_graph_overflows() then kept
iterating over a graph that could no longer grow: a 53 KB font with 150
MarkBasePos subtables sharing one 8400-anchor BaseArray ran one core for
~705 s before failing, instead of ~37 s.

duplicate_subgraph() now returns the recorded error with TRY(result).
_resolve_shared_overflow() treats only INVALID_ARGUMENT (the node
genuinely cannot be duplicated here) as "not resolved" and propagates
LIMIT_EXCEEDED/ALLOCATION_FAILURE/OUT_OF_BOUNDS, restoring the
pre-conversion behaviour where the sticky error ended the loop; this is
the same error-discrimination idiom already used for SANITIZE_FAILURE in
hb-repacker.hh and ORPHANED_NODES in graph.hh.

Two regression tests are added to test-repacker.cc, each failing without
its hunk.  Behaviour change: reaching the vertex limit now fails
promptly as before 14.5.0; no public API/ABI change.

Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-I0BMRXN4.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-30 15:37:38 -06:00
Behdad EsfahbodandClaude Opus 4.8 c8e9f14fd3 [repacker] Reject link positions that wrap near UINT_MAX
graph_t::vertex_t::link_positions_valid() computed a link's last byte
as start + width - 1 in 32-bit arithmetic, so a caller-supplied
position near UINT_MAX wrapped to a small value and passed the bounds
test; the defense-in-depth guard in serialize_link_of_type() summed
link.position + link.width the same way.  A graph with a link at
position 0xFFFFFFFF was therefore accepted by
hb_subset_serialize_or_fail() and the serializer stored the offset
field about 4 GiB past the output buffer (SIGSEGV on 64-bit).

Reject the link when end < start (width is already confined to 2..4 at
that point, so this means start + width wrapped), and rewrite the
serializer guard as position > size || size - position < width, the
no-sum idiom used elsewhere for range checks.

Only a caller that computes its own bad link position reaches this;
the subsetter's own graphs always take positions from inside the
object, so no font, text or subsetting request leads here.  Valid
graphs are unaffected and there is no public API/ABI change.

A regression test, test_invalid_link_position(), is added next to the
existing invalid-link tests; it crashes on the unpatched code.

Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-GREQ3M7K.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-30 15:37:38 -06:00
Behdad Esfahbod f9fcba7272 [repacker] Prevent matrix vertex size checks from wrapping (#6491)
AnchorMatrix's offset array size was multiplied in unsigned arithmetic.
A small vertex with 46341 rows could therefore be accepted as a
46341-column matrix, leading to excessive work and allocation during
subtable splitting. PairPosFormat2 had the same problem on 32-bit
platforms.

Use the existing size_t saturating multiply helper and compare against
the payload length after checking the header. This preserves the width
of PairPosFormat2's size computation and avoids overflow in the header
addition as well.

Add bounded internal vertex tests for wrapping dimensions, exact valid
sizes, truncated payloads and headers, and empty matrices. The anchor
regression fails against the unchanged code without large allocations.

Discovered by Anthropic's OSS Scanner, as vulnerability
ANT-2026-7E6A2QQS.

Testing: meson compile -C build -j4; meson test -C build
(all 274 tests passed).

Assisted-by: OpenAI Codex
2026-10-30 14:51:09 -06:00
Behdad Esfahbod d8347f079e [repacker] Count null offsets when splitting ligatures (#6476)
Ligature split points skipped null offsets while the ranges used to
clone and shrink subtables counted every slot. Advance the split index
for null offsets too, so both stages refer to the same ligatures.

Also reject an inverted range after narrowing it to the remaining
links, before calculating the number of ligatures to allocate.

Add a regression that compares the split graph with the expected
subtables when one ligature set has trailing null offsets.

Testing: meson test -C build (292 passed; check-symbols skipped on
macOS), plus the repacker test and shared-ligature font check with
ASan and UBSan.

Discovered by Anthropic's OSS Scanner, as vulnerability
ANT-2026-9C9WB0KM.

Assisted-by: OpenAI Codex
2026-10-29 21:00:03 -06:00
Behdad Esfahbod 21a2f7c43e [repacker] Reject output sizes that cannot fit a blob (#6478)
The graph total is size_t, while the output vector allocation takes an
unsigned int. Check the total against the blob length limit before that
conversion, so the allocation and serialization context use the same
size. Totals above INT_MAX cannot produce a valid output blob anyway.

Add a public-API regression whose objects share their backing storage,
keeping its memory use small while exercising a large graph total.

Testing: meson test -C build (292 passed; check-symbols skipped on
macOS), plus test-subset-repacker with ASan and UBSan. The regression
reproduces the invalid write without the check and fails cleanly with it.

Discovered by Anthropic's OSS Scanner, as vulnerability
ANT-2026-4Q0YO46E.

Assisted-by: OpenAI Codex
2026-10-29 20:56:03 -06:00
Behdad Esfahbod ecf0bc81aa [subset] Keep ClassDef range traversal in sync for class zero (#6473)
The class-zero intersection loop skipped ranges starting at glyph 0
without advancing the last glyph, and consulted a separate iterator
instead of the range being visited. Probe only actual gaps and always
advance past each range, so unlisted glyphs retain class-zero rules.

Check all 256 glyph sets over eight glyphs against per-glyph class
lookup for empty, contiguous, gapped, and explicit class-zero ranges.
The regression fails on the old source. The full Meson suite passes
(293 tests), including shape and subset.

Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-K9HEP9ZU.

Assisted-by: OpenAI Codex
2026-10-29 19:30:56 -06:00
Behdad Esfahbod 4cf1474dfa [repacker] Reset graph state before assigning spaces
Overflow resolution can retry GSUB/GPOS specialization on an already
modified graph.  Clear derived space and priority state before assigning
spaces again so retries do not accumulate stale space identifiers.

Use the full signed range available to the packed distance key instead
of saturating valid distances as the number of spaces grows.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-02 02:36:32 -06:00
Behdad Esfahbod 22248564c1 [repacker] Move already-isolated overflow roots
Initialize every selected root's incoming-edge count before traversing
their combined subgraph.  This prevents later root initialization from
overwriting counts collected through an earlier root.

An overflow root still needs a new packing space when no duplication is
needed, so move already-isolated roots instead of treating that case as
an unsuccessful resolution attempt.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-02 02:36:20 -06:00
Behdad Esfahbod 5b104f8afe [repacker] Handle extended layout graphs
Discover GSUB/GPOS 1.2 lookups through LookupList2 and treat the
32-bit lookup-list link like other wide graph roots.  Also preserve
parent multiplicity when identical lookup subtables are promoted to a
shared extension wrapper.

Add coverage for 1.2 extension promotion and repeated subtable links.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-02 02:35:55 -06:00
Behdad Esfahbod d2e218ac26 [layout] Use 24-bit ClassDef format 3 values
ClassDef format 3 stores startGlyphID, glyphCount, and each class value
as uint24.  Use the medium integer type for the class array, select a
serializable format based on both glyph and class ranges, and keep the
subsetter size estimator in sync.

Test parsing and querying a class value above 65535, and test that the
serializer and size estimator select the matching format.

Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-10-01 13:29:55 -06:00
Behdad Esfahbod 17af97aae4 Merge remote-tracking branch 'origin/main' into beyond-64k
Reconcile the beyond-64K table type changes with the dependency API,
graph result handling, and variation-budget updates from main. Preserve
the branch's wider table variants while adopting the new behavior.

Build and test with Meson (281 passed, 1 skipped).

Assisted-by: OpenAI Codex <noreply@openai.com>
2026-10-01 12:59:54 -06:00
Kevin Hellemun 0d0b62575f fix(gcc 4.9.4): compilation errors
The current build for v14.5.0 fails to compile on gcc 4.9.4 which is
used on embedded Kobo systems. 

Ref: https://github.com/OGKevin/cadmus/pull/1005

Change-Id: 7a4bec5b5418bd0921b273d8d4a1e79b
Change-Id-Short: spvolnuouvyr
2026-09-21 11:02:29 -06:00
Garret Rieger 2a6c6b9b90 Add test for hb_result_t::from() that moves the input. 2026-09-04 17:08:08 -06:00
Garret Rieger 18d0fd1a6c Rework TRY macro to work the MSVC:
Split into one macro for void results, and a new TRY_ASSIGN() for when the Ok() value needs to be assigned.
2026-09-04 17:08:08 -06:00
Garret Rieger 2f291a46ae Convert repacker and graph code to utilize to hb_result_t.
Converts all error handling in the repacker/graph code to use hb_result_t.
2026-09-04 17:08:08 -06:00
Garret Rieger 8d08f87417 Fix possible memory leak in coverage-graph.hh 2026-08-27 21:11:10 +00:00
Garret Rieger 367657d74d Add some missing checks for alloc failure in repacker. 2026-08-27 21:11:10 +00:00
Garret Rieger 15fe46ee28 Use value instead of pointer in overflow record dedup.
Avoids issues with ownership of pointer memory.
2026-08-27 21:11:10 +00:00
Garret Rieger a897489430 Add HB_GRAPH_INVALID constant for marking error results in graph/repacker code. 2026-08-27 14:22:26 -06:00
Garret Rieger 7eac03d53c Add missing error handling for fallible operations in the repacker. 2026-08-27 14:22:26 -06:00
Garret Rieger 5f16f4ba68 In pair pos format 2 splitting only recompute coverage size when the included glyph set changes.
Assisted by Gemini
2026-08-26 14:24:53 -06:00
Garret Rieger c31bd6797a More documentation for traverse_directed_bfs(). 2026-07-31 18:05:07 -06:00
Garret Rieger 197d38a8a3 [subset] Convert repacker graph traversals to BFS.
None of the traversals require DFS order so BFS can be used instead which eliminates the possibility of stack overflow. For the queue we re-use the existing ordering_scratch_ space to avoid allocating any additional memory. As a bonus this fixes a bug in find_32bit_roots() that was the result of DFS traversal order.

All of the directed traversal methods are unified to a single common implementation.
2026-07-31 18:05:07 -06:00
copilot-swe-agent[bot] 96f6aa848a Merge branch 'main' into beyond-64k
Resolve conflicts by taking hb_barrier() additions from main for all
switch dispatchers (COLR, Coverage, CursivePos, SinglePos,
ReverseChainSingleSubst) while keeping the beyond-64k extended
format cases.

For GDEF.hh: take main's clean GDEFVersion1_2<Types> template union
approach (which already handles beyond-64k via GDEFVersion1_2<MediumTypes>)
and incorporate the LigCaretList<Types> templating from beyond-64k,
expanding get_lig_carets() and collect_variation_indices() to dispatch
directly per version.

For coverage-graph.hh: keep beyond-64k's <Types> template but add
main's const qualifier to the vertex parameter.

For gsubgpos-graph.hh: keep beyond-64k's delegation to
OT::GSUBGPOS::get_lookup_list_field_offset() since GSUBGPOS uses the
flat struct approach in this branch.

For hb-ot-cmap-table.hh: keep beyond-64k's find_variation_selector_subtable()
which handles both format 14 and format 15 (beyond-64k).

Also fix PaintGlyph<Types>::paint_glyph out-of-line template definition
to include the template parameter, incorporating the get_solid_color
optimization from main.

Assisted-by: GitHub Copilot
2026-07-29 17:48:41 +00:00
Behdad Esfahbod da7f951ef0 Add more hb_barrier()s in switches (#6106)
Fixes https://github.com/harfbuzz/harfbuzz/security/advisories/GHSA-pmg2-m89x-pc6j
2026-07-27 19:20:18 -06:00
Qunxin Liu 2c875edbb6 [subset-repack] bug fixes (#6088)
* [subset-repack] fix potential out of bounds accesses

make sure we create a deep copy of the object before we mutate

* [subset-repack] fix is_shared(): only check real parents

* [subset-repack] add tests

* [subset-repack] apply AI proposed change

* address review comments

* [subset-repack] no need to duplicate shared liga_sets beforehand

Since we now would create a memory copy of the object before mutating
it, I think checking and duplicating shared liga_sets is not needed.
2026-07-21 11:49:06 -06:00
Qunxin Liu 8207419e0a [subset-repack] increase REPACKER_MAX_VERTICES limit to 800000 2026-07-21 11:16:26 -06:00
Behdad Esfahbod fc85680fec Revert "[subset-repack] bug fixes (#6077)"
This reverts commit 0b590d6b54.
2026-07-21 10:59:48 -06:00
Qunxin Liu 0b590d6b54 [subset-repack] bug fixes (#6077)
* [subset-repack] fix potential out of bounds accesses

make sure we create a deep copy of the object before we mutate

* [subset-repack] fix is_shared(): only check real parents

* [subset-repack] add tests

* [subset-repack] apply AI proposed change

* address review comments

* [subset-repack] no need to duplicate shared liga_sets beforehand

Since we now would create a memory copy of the object before mutating
it, I think checking and duplicating shared liga_sets is not needed.
2026-07-21 10:55:43 -06:00
Behdad Esfahbod 882ce8e6f3 [layout] Use 32-bit lookup offsets in LookupList2
Make the GSUB/GPOS v1.2 LookupList2 path use LookupList<MediumTypes>,
so the lookup count remains 16-bit while per-lookup offsets are widened
to 32 bits. Runtime lookup access now branches between the lower and
upper lookup-list layouts.

As of June 2026, the proposed GSUB/GPOS v1.2 spec points LookupList2 at
LookupList, which would leave per-lookup offsets at 16 bits. Note that
HarfBuzz intentionally widens those offsets because the proposed shape is
not suitable for beyond-64k fonts.

Keep the graph repacker on lower GSUB/GPOS tables for now, since it walks
the raw lookup-list object layout.

Testing: meson compile -C build util/hb-subset test-repacker
Testing: meson test -C build --suite shape --suite subset
Testing: build/util/hb-shape /tmp/fonttools-noto-sans-lookuplist2/NotoSans-merged.ttf 'test'
Testing: build/util/hb-shape /tmp/fonttools-noto-sans-lookuplist2/NotoSans-merged.ttf 'කොහොමද'
Testing: build/util/hb-shape /tmp/fonttools-noto-sans-lookuplist2/NotoSans-merged.ttf 'क्षि'

Assisted-by: OpenAI Codex
2026-06-07 20:59:44 +02:00
Behdad Esfahbod b1c5f20ef8 [layout] Keep extended ClassDef values 16-bit
ClassDef format 3 extends the glyph ID and glyph count fields,
but class values remain uint16.  Reading them through Types::HBUINT
made format 3 dense class arrays use a 24-bit stride, so class
lookups could return zero for valid glyphs.

Update the graph size estimator to use the same fixed value width
and compare concrete format sizes instead of using the old shortcut.

Tested with `meson test -C build`.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-06-06 13:55:38 +02:00
Behdad Esfahbod 2a543ecdd4 [layout] Align extended offsets with spec
Coverage format 3 and 4 widen their array counts, and coverage
range records also widen the coverage index value.  Account for the
larger records in the graph size estimator.

Use 32-bit top-level offsets where the extended GSUB/GPOS/context
formats specify long offsets, while leaving nested offset arrays as
24-bit offsets.  SequenceRuleSet2 is the exception where the rule-set
array offsets stay 16-bit and only the rule contents use extended
widths.

Tested with:
- meson compile -C build util/hb-shape
- git diff --check

Existing fontTools-generated Sinhala upper-case test fonts still lose
GSUB/GPOS script data and need follow-up debugging.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-06-06 13:19:16 +02:00
Behdad Esfahbod e6aeb529a4 [ot] Move shared types and dual helpers together
Move SmallTypes, MediumTypes, and the dual table accelerator
helpers into hb-ot-dual.hh. Keep Layout cache aliases in Layout
common and update standalone users to include the shared header.

Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:49:01 +02:00
Behdad Esfahbod 19de83dad2 [graph] Keep ClassDef size estimates incremental
Maintain the encoded ClassDef glyph set and range count as classes
are added instead of reconstructing them for every size estimate.

This avoids quadratic PairPos splitting on large class definitions.

Assisted-by: OpenAI Codex
2026-06-05 12:38:55 +02:00
Behdad Esfahbod 0bf6733c0e [graph] Reject non-v1 GSUB/GPOS graph roots
The repacker graph sanitizer accepted non-v1 GSUB/GPOS roots
because GSUBGPOS::get_size() returns only the version field size
for unsupported major versions. Graph specialization then still
consulted the numeric version and could read the v1.2 lookupList2
field from a too-small fuzz object.

Require version major 1 before using GSUB/GPOS graph-specific
lookup discovery.

Testing: meson test -C build test-repacker test-classdef-graph
Testing: meson test -C build --suite subset
Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:52 +02:00
Behdad Esfahbod 336d65cdab [graph] Guard beyond-64k classdef graph tests
The default build has HB_NO_BEYOND_64K enabled, so serializers reject
glyph IDs above 0xffff with an integer-overflow error. Keep the high
glyph ClassDef size checks for beyond-64k builds only.

Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:52 +02:00
Behdad Esfahbod 813558d2e9 [gpos] Template mark attachment arrays
MarkBasePos, MarkLigPos, and MarkMarkPos format 2 use nested
MarkArray2, BaseArray2, LigatureArray2, and Mark2Array2 tables
with 24-bit counts and offsets in different combinations.

Template the shared mark records and anchor matrices so format 1
continues to use SmallTypes while format 2 uses the widths specified
for the beyond-64k layout forms. Keep the subset graph wrappers bound
to their existing 16-bit forms.

Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:52 +02:00
Behdad Esfahbod ef538ebafa [graph] Clarify 24-bit layout splitter policy
Update graph splitter comments to document that 24-bit layout formats
are intentionally left unsplit because their relevant offsets are
already widened.

Testing: not run; comment-only change.

Assisted-by: OpenAI Codex
2026-06-05 12:34:51 +02:00
Behdad Esfahbod 8a7a5e9baa [graph] Account for 24-bit ClassDef size estimates
Update the ClassDef and Coverage size estimator used by graph
splitting to derive glyph and range widths from the included glyphs
instead of assuming 16-bit table formats. Keep ClassDef size selection
aligned with the serializer heuristic, including class breaks and the
fact that class zero is not encoded in ClassDef tables.

Add high-glyph test cases that compare the estimator against actual
24-bit ClassDef and Coverage serialization sizes.

Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:51 +02:00
Behdad Esfahbod fb91f3be90 [graph] Support 24-bit Coverage sanitization
Template the graph Coverage sanitizers on the layout type width and
dispatch formats 3 and 4 through the MediumTypes variants. This lets
graph sanitization accept 24-bit Coverage tables instead of rejecting
those formats outright.

Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:51 +02:00
Behdad Esfahbod 5f8d73cbe9 [graph] Support 24-bit ClassDef sanitization
Template the graph ClassDef format wrappers on the layout type width
and dispatch formats 3 and 4 through the MediumTypes variants. This
lets graph sanitization accept 24-bit ClassDef tables instead of
rejecting those formats outright.

Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:51 +02:00
Behdad Esfahbod a1a1002e59 [layout] Fold GSUB/GPOS version handling into header
Move the GSUB/GPOS versioned header fields back into GSUBGPOS
and select the active ScriptList, FeatureList, and LookupList
offsets from the table version.

Version 1.2 now uses the spec's 32-bit offset2 fields when they
are present, while the common list internals remain the existing
16-bit layout structures.

Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:51 +02:00
Qunxin Liu 209a7237b9 [repacker] fuzzer fix: duplicate shared liga_sets before splitting (#5972)
fix for: https://oss-fuzz.com/testcase-detail/5291844211900416
2026-05-01 14:50:05 -06:00
Behdad Esfahbod 2adb01a47c [internal] Replace remaining vector resize(0) with clear()
Two callers were still using vector.resize(0) to drop accumulated
data: graph/serialize.hh's overflow tracking and hb_bit_set_t's
clear() (via its own internal resize()).  resize(0) on a vector
in error state short-circuits without zeroing length, leaving
stale entries that downstream code then walks as if valid.

Fix both:

 - serialize.hh: call overflows->clear() instead.
 - hb-bit-set.hh: reimplement clear() to zero length/population
   unconditionally by calling pages.clear() / page_map.clear()
   directly, bypassing the internal resize() that bails when
   `successful` is false.

Mirrors the March clear() fix in hb-vector.hh (commit d134f88824).

Assisted-by: Claude <noreply@anthropic.com>
2026-04-14 22:04:57 -06:00