ClipList::subset() walked startGlyphID..endGlyphID of every ClipRecord,
which is only O(num_glyphs) overall when the records are sorted and
disjoint. ClipList::sanitize() checks neither, so R overlapping records
each spanning all glyphs cost R x 65535 iterations: a 332 KB font with
10000 whole-range records took about 20 s of CPU in hb-subset whatever
glyphs or text the request asked for.
Invert the loop: iterate the retained glyph set once and find each
glyph's record with clips.as_array ().bsearch (gid), exactly how
ClipList::get_extents() resolves a glyph's clip box when rendering, and
the same shape as the COLRv0 path in COLR::subset(). Cost is now
O(|glyphset| log R) regardless of record overlap. For well-formed
(sorted, disjoint) lists the output is unchanged; for malformed
overlapping/unsorted lists the chosen record can differ (bsearch instead
of last-record-wins), which makes the subset agree with the clip box
HarfBuzz itself renders from the source font.
Adds an extended-format hb-subset-fuzzer input (5000 records covering
all 65535 glyphs) that the subset-fuzzer tests pick up.
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-MRSCGMJ7.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
COLR::subset() gives every retained COLRv0 base glyph a private copy of
its layer range, so N base glyphs sharing L layers cost N x L layer
copies with two hash lookups each, and nothing checked the total against
the 16-bit numLayers header field. serialize_V0() walks the lazy
iterator twice and _hb_subset_table_try() retries while doubling the
buffer, so a ~200 KB font with all records naming the same range kept
hb-subset busy for about two minutes before failing.
Cap the summed layer count with a cheap walk over base_it before layer_it
is built, and drop COLR (return_trace (false)) when the total exceeds
0xFFFF, the same way this function already handles V0 records it cannot
subset; this also removes the 16-bit wrap in serialize_V0(). Any total
above 65535 could only have produced a failed subset or a wrapped,
invalid numLayers, so no valid output is lost.
The two V0 closure helpers had the same N x L shape during planning;
collect the layer indices of all retained base glyphs into one set first
and visit each layer once. closure_glyphs() now takes the glyph set in
one call (the accelerator wrapper changes signature with it; no public
API change), and _colr_closure() passes the whole set instead of looping.
Adds test_subset_colr_shared_layers (256 base glyphs all claiming the
same 256 layers): retaining 255 gives a 65280-layer table, retaining all
256 gives an empty COLR.
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-4T7NHCTK.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
PaintColrLayers::closurev1() recorded firstLayerIndex ..
firstLayerIndex + numLayers - 1 as retained layers without checking
the range against LayerList.len (PaintColrLayers::sanitize is a plain
check_struct), and _colr_closure() then creates one colrv1_layers map
entry per retained index. A crafted font whose leaf paints point past
the end of the LayerList could therefore add up to 255 entries each for
layers that do not exist, driving subset-plan memory to roughly 1200x
the font size (585 MiB for a 512 KB font).
Clamp the range to the LayerList at the one place the retained-layer set
is built, before add_layer_indices() and for the dispatch loop alike;
this also removes the firstLayerIndex + numLayers wrap-around in the loop
bound. Readers (paint_glyph, dependv1) never record indices and already
tolerate out-of-range ones via LayerList::get_paint() returning Null, so
they are left alone. A PaintColrLayers whose range lies past the source
LayerList now has no mapping and subset writes 0xFFFFFFFF; both that and
a renumbered index past the new LayerList are out of range and draw
nothing.
Adds a regression test that builds such a font inline and pins the
output; it fails without the fix.
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-ROQFK0RA.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The draw encoder returns the empty blob for outlines without curves.
Treating it as a clip sub-blob leaves a layer referring to the next
payload or the end of the encoded data. Cache empty glyph and path
clips separately and skip their consuming layers. Preserve the
paint encoder's no-ink contract when only group operations remain,
returning an empty blob with zero extents.
Use fallible blob creation for gradient payloads so allocation failure
cannot produce the same zero-length sub-blob references.
Add an API regression using an ordinary font and paint callbacks,
covering solid and gradient layers, empty paths, groups, and clip slot
reuse. Validate the surviving layer's outline and band references.
The regression fails on the original encoder; the full Meson suite
passes (274 tests).
Reported by Anthropic's OSS Scanner as ANT-2026-5Z1FLVCW.
Assisted-by: OpenAI Codex
hb_pair() preserves references to lvalue arguments. The alternate
collection callbacks returned pairs referencing their own by-value
parameters, so the next iterator stage read them after the call ended.
Pass each AlternateSubst glyph directly to the collector helper, which
already encodes its alternate index. This also keeps alternate_count
keyed by the original glyph. Return a value pair for SingleSubst format
1, as the subsetting path already does.
Cross-check collected maps against the per-glyph getter for four
SourceSansPro lookups. The alternate and both SingleSubst format 1
cases fail on the previous code; the format 2 control passes.
Testing: meson test -C build (292 passed; check-symbols skipped on
macOS). All five alternate API tests also pass under ASan and UBSan,
with stack-use-after-return detection enabled.
Discovered by Anthropic's OSS Scanner, as vulnerability
ANT-2026-N7S3EYU4.
Assisted-by: OpenAI Codex
Use one hidden user-data key for vector blob metadata. A static key in
its header gives each renderer a different address, so a blob recycled
between renderers can retain a user-data entry for released metadata.
Clear in_replace after replace_buffer() returns, including when the
buffer stays at the same address and its destroy callback is skipped.
Otherwise the final destruction keeps the metadata allocation alive.
Exercise cross-renderer and in-place recycling in all four SVG/PDF draw
and paint paths. The cross-renderer case fails under ASan before the
fix. With the fix the sanitizer check and all 293 Meson tests pass, and
macOS leaks reports no leaks (five metadata allocations before clearing
the in_replace flag).
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-HAG1BPA1
and ordinary bug ANT-2026-YE77VHKY.
Assisted-by: OpenAI Codex
Check the combined image-data length for unsigned overflow and ensure
it fits the vector's signed length argument. Resize the output only
after those checks, then copy at the saved old length. Both callers
already propagate failure to the serializer.
Extend the allocation-failure test with small simulated boundary cases
for an unrepresentable total and a wrapping sum. Each starts with a
fresh vector, and the allocator refuses large requests as a backstop.
The new regression fails before the fix without allocating large
buffers. All 293 tests pass, and test-cbdt-cache passes under ASan and
UBSan, including the existing required-allocation failure checks.
Discovered by Anthropic's OSS Scanner, as vulnerability
ANT-2026-N6HMDRS8.
Assisted-by: OpenAI Codex
The glyph slot belongs to the shared FreeType face. Copy its bitmap
and dimensions before releasing the face lock, then query extents
and invoke the image callback without the lock. Fail if the bitmap
copy cannot be allocated.
Add a bounded shared-font paint regression using the existing emoji
fixture. Check BGRA blob dimensions and reenter the font from the
image callback. The test crashes before the fix and passes after it.
The full Meson suite passes (274 tests).
Reported by Anthropic's OSS Scanner as ANT-2026-ANVKHBVD.
Assisted-by: OpenAI Codex
hb_sanitize_context_t::writable is only ever written (in the
constructor and init()) and never read. The edit/neuter code that
consulted it was removed in 665afc08f6 ("[sanitize] Remove
table-altering code parts") and 83dc4d1d35 ("[sanitize] Don't do
edit-sanitize cycle"); the flag was left behind as dead state.
Remove it. No functional change; the full Meson suite passes
(274 tests).
Assisted-by: Claude Opus 4.8 <noreply@anthropic.com>
Require each format 10 value to occupy at least one byte. Otherwise a
lookup can declare covered glyphs without backing data for those values,
bypassing the sanitizer work charged for checking the array.
Add a compact lookup sanitizer regression covering sizes zero through
five, existing supported sizes, and truncated payloads. The regression
rejects the original zero-sized case and accepts the supported controls.
All 294 Meson tests pass, including the shape suite, and the new test
passes under ASan and UBSan.
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-F9Y85YHV.
Assisted-by: OpenAI Codex
Check ensure(glyph_count) before writing Graphite output. Release the
feature values and segment and return failure when buffer growth fails.
Add a small synthetic font and a bounded regression that refuses buffer
growth via max_len. The normal path produces 164 glyphs; the failure path
retains the original input length and reports allocation failure. Include
the font generator, whose output matches the checked-in fixture.
The new regression fails before the fix under ASan and passes afterward.
All 276 tests pass with Graphite2 enabled; the regression also passes under
ASan and UBSan.
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-HEQW39B7.
Assisted-by: OpenAI Codex
Release the face lock around solid, gradient, and custom palette
callbacks. Keep lazy FreeType color-stop reads locked and give each
getter call its own iterator, so callbacks can query the same font
without deadlocking or disturbing another stop query.
Snapshot the selected palette once per COLRv1 traversal, shared by
the bounds and paint passes. Nested paints can select a different
palette on the face; they must not change the outer paint's colors.
Return failure if the palette copy cannot be allocated. Stops remain
lazy and no cache policy or limits change.
Add a bounded callback regression with the existing COLRv1 fixture.
It queries font extents, performs nested paints with another palette,
and checks repeated and paged stop reads against the OT backend.
The original code times out; unlocking without copying the palette
fails the color comparison. The full Meson suite passes: 274 tests, no failures.
Reported by Anthropic's OSS Scanner as ANT-2026-YPLDSFHA.
Assisted-by: OpenAI Codex
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
Keep the memory-backed FT_Face blob on the hb_face_t even when the
OpenType sanitizer discards its copy. Otherwise the destroy callback
can release the FT_Face while the face or font still uses it. Return
the empty object on allocation failure before accessing that pointer.
Keep a blob loader's input bytes on the FT_Face rather than the
hb_face_t, since retained table blobs can outlive the latter. Keep the
library reference on the input blob and release it outside the static
FreeType mutex. Initialize file-loader ownership before transferring
references as well.
Add regressions for destroy-callback timing, referenced font lifetime,
and table blobs retained past the source face. All 293 tests pass,
including all eight FreeType subtests under ASan and UBSan. A separate
sanitized ownership probe passes 154 allocation-failure cases.
Discovered by Anthropic's OSS Scanner, as vulnerabilities
ANT-2026-FC0F75Y2 and ANT-2026-O2E5WAA5.
Assisted-by: OpenAI Codex
Cursive lookups with different flags can create an attachment cycle.
The const cross-offset walker then follows it forever when attaching
a mark. An acyclic chain over len glyphs has at most len - 1 links;
stop at that bound while retaining every valid forward and backward
chain and the existing offset accumulation behavior.
Add an in-house shaping regression instead of a bespoke unit test:
a tiny payload font whose two cursive lookups (one RightToLeft, one
IgnoreMarks) close an A -> B -> C -> A cycle, with a MarkBasePos that
attaches a mark onto C. Shaping ABCD looped forever before the fix and
now terminates. The original hang is reproduced on the unpatched tree;
the patched build shapes it identically under the ot and ft font-funcs.
The full Meson suite passes (274 tests), including shaping.
Reported by Anthropic's OSS Scanner as ANT-2026-PRD7EFA6.
Assisted-by: OpenAI Codex
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
process_() moves the kept page_map entries to the front and renumbers
their pages with compact() before calling resize(count), which can fail
when the operation grows the set (passthru_right without passthru_left:
union with an inverted set, intersect of an inverted set, subtract of two
inverted sets). On failure the set kept its old page_map/pages length with
a duplicated, unsorted map; hb_bit_set_t::set() copied that state into a
fresh set that reported success, and a later del_range()/add() then indexed
pages out of bounds.
compact() already knows the kept length, so truncate page_map and pages to
it with shrink(length, false), which cannot fail. The set is now consistent
before any fallible growth, and del_pages() no longer needs its own resize()
after compact().
Only host programs doing mixed inverted/normal hb_set_t arithmetic under a
failing allocation reach this; HarfBuzz itself never runs the operation on a
non-empty left set, so it is an ordinary bug, not a security issue.
A regression test in src/test-set.cc simulates the allocation failure for
both process() and del_range() and checks the resulting lengths and map.
Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-LG3UXUGW.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Format 2 class values are byte offsets, but ExtendedTypes::offsetToIndex
leaves them unchanged. Use byteOffsetToIndex to convert their sum to an
FWORD index. ObsoleteTypes retains the existing kern format 2 behavior.
Add a synthetic font and shaping regressions covering negative and
positive kerning, the final array entry, zero classes, missing lookup
entries, and disabled kerning.
The shaping regression fails without the fix. The full Meson test suite
passes, and Helvetica Light's LY, AY, Hi, and HH kerning matches CoreText.
Fixes: https://github.com/harfbuzz/harfbuzz/issues/6461
Assisted-by: OpenAI Codex
Glyph zero is always reserved for .notdef. Reject mappings that assign
another retained glyph to it, so the output list has one entry per id.
Also bound the resulting glyph count by the widest supported count
field, MAXP's HBUINT24. Account for the unmapped glyphs and the initial
slot before assigning ids, avoiding wraparound and oversized counts in
table subsetters. The limit applies to the count, not the highest id.
Document these constraints and test valid renumbering, gaps, ignored
remapping of .notdef, reserved-id collisions, and out-of-range counts.
The regression and stock hb-subset both reproduce the issue under ASan
before the fix. All 293 tests pass after it, including the subset suite;
the API subset tests and command-line checks also pass ASan and UBSan.
Discovered by Anthropic's OSS Scanner, as vulnerability
ANT-2026-6I1RIFMQ.
Assisted-by: OpenAI Codex
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
Reject allocation requests above INT_MAX before growing the capacity,
and cap geometric growth at that limit. Otherwise the unsigned growth
loop can wrap, or a successful allocation can store a negative value
in the signed capacity field. Normalize exact requests before checking
the limit so the existing length is included.
Test both normal and exact oversized requests, preservation of existing
contents on failure, and saturation of geometric growth. Intercept the
allocator in the unit test to avoid allocating large buffers. The new
regression fails before the fix. All 293 tests pass, and test-vector
passes under ASan and UBSan.
Discovered by Anthropic's OSS Scanner, as vulnerability
ANT-2026-N6HMDRS8.
Assisted-by: OpenAI Codex
A custom glyph mapping can leave unassigned output glyph IDs beyond
the source glyph count. The preprocessing glyph-to-SID map only covers
source glyphs, so use the existing charset lookup for those gaps and
skip the map-based range shortcut there.
Compare plain and preprocessed subsets of existing name-keyed and
CID-keyed fonts with output gaps. The new regression fails under ASan
before the fix. The complete ASan/UBSan Meson suite passes afterward
(293 tests, including 23 CFF1 API subtests).
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-42ZOI3TR.
Assisted-by: OpenAI Codex
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
The saturating size helper returns size_t, so assigning its product to
unsigned can truncate it before the UINT_MAX check. Check multiplication
at unsigned width before resizing the buffer used by compile_unsafe().
Validated the reported high-count case under ASan/UBSan: it fails cleanly
after this change. A small control produces byte-identical output. The
ASan/UBSan Meson suite passes; check-symbols also passes after generating
its symbol manifests.
The large input remains a manual regression because it requires several
GB of memory.
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-V0UYCX4C.
Assisted-by: OpenAI Codex
A missing component skipped a fallback ligature but left its partial
component list counted. Later ligatures then used the wrong letters.
Write tentative components at the current offset and advance the
count only after every component has matched.
Add a generated GSUB-less font and two shaping regressions, covering
both the wrong ligature and the valid ligature it displaced, with ot
and ft font functions. All four cases fail before the fix. The full
Meson suite passes (293 tests, 6227 in-house shaping subtests).
Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-EMRGZ57Y.
Assisted-by: OpenAI Codex
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
The PDF draw renderer emitted paths in Y-up coordinates but vertically
mirrored the MediaBox and background rectangle. Use the same extents
for the content, page, and background, matching the paint renderer.
Regenerate the existing PDF fixture with hb-vector. Only the page box
and background coordinates change. Its page now covers the glyphs'
outline Y range; the old page did not. The updated vector regression
fails on the old source. The full Meson suite passes (293 tests).
Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-0ER2GEWZ.
Assisted-by: OpenAI Codex
The SVG body is flipped from font coordinates once at render time.
The path-clip callback still emitted its own vertical flip from the
older renderer, mirroring the clip relative to the drawing. Remove
that transform, matching rectangle and glyph clips.
Add a paint/show-extents vector regression and generate its expected
SVG with hb-vector. It fails on the old code. The full Meson suite
passes (293 tests).
Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-BZKWFGVZ.
Assisted-by: OpenAI Codex
The baseline fallback accepts an OpenType script tag but compared it
with hb_script_t values. Convert the tag before choosing the glyph
used to synthesize the hanging baseline.
Exercise Bengali's old and new OpenType tags, Tibetan, and the script
and language entry point. The updated test fails before the fix
(622 versus 600); the full Meson suite passes (293 tests).
Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-COIT72UF.
Assisted-by: OpenAI Codex
* [var] Recalculate intermediate tuples with a cached zero scalar
The shared-tuple scalar cache describes the default region around a
shared peak. An intermediate region can extend beyond that peak, so a
cached zero need not mean its own contribution is zero. Only reuse a
cached one for intermediate tuples; otherwise evaluate their region.
Check cached and uncached results across the axis range and in both
tuple evaluation orders. The regression fails before the fix. The
full Meson suite passes (293 tests), including the shape suite.
Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-RTBS23VC.
Assisted-by: OpenAI Codex
* [var] Drop cache reuse for intermediate tuples
Keep the plain shared-tuple cache fast path and remove the secondary
probe for intermediate tuples. Evaluate their own regions and disable
cache writes before the axis loop, including at exact peak locations.
This also removes the redundant per-axis cache-pointer reset.
The full Meson suite passes (293 tests), including the cache regression
and the shape and subset suites.
Follow-up for ordinary bug ANT-2026-RTBS23VC.
Assisted-by: OpenAI Codex
The point-in-quad test rejected the interior side of each edge for
both winding orders. Reverse the comparisons for rectangle and mask
intersections, and clarify how the edge normal depends on winding.
Add a regression for skew, reflected skew, and rotation, with one or
two nested rectangle clips to exercise both intersection paths. The
center pixel was transparent before the fix. The full Meson suite
passes (293 tests).
Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-AM92X98M.
Assisted-by: OpenAI Codex
The bounds vectors used to rebuild hhea and vhea expect non-negative
widths and heights, with a sentinel for glyphs without outlines.
CFF2 instancing stored negative extents.height values and replaced the
sentinel for empty glyphs. Store yMax - yMin and preserve empty bounds.
Regenerate the three affected expected fonts through the subset test
generator. Only header metrics and checksums change. The new vhea
values agree with FontTools recalculation from the glyph outlines.
Both affected test cases fail without the source fix; the full Meson
suite passes with it (293 tests).
Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-3LQ6CVVN.
Assisted-by: OpenAI Codex
Fonts without vhea returned the ascender for the vertical descender
metric. Read the descender from the synthesized vertical font extents,
as the horizontal fallback already does.
Add a regression comparing all three fallback vertical metrics with
the font extents. It fails before this change (1024 versus -1024).
The full Meson suite passes (293 tests).
Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-4UNO2SK8.
Assisted-by: OpenAI Codex
CFF1 INDEX counts are 16-bit. Serializing a larger iterator truncated
its count before reserving the offset array, then wrote offsets for
every item. Check the count before allocating or writing the offsets.
Test the CFF1 boundary and the corresponding valid CFF2 counts, and
reject a subset glyph mapping that overflows the CharStrings INDEX.
Both regressions fail before this change. The full Meson suite passes
(293 tests), including the subset and API suites.
Discovered by Anthropic's OSS Scanner, as vulnerability
ANT-2026-8ROS1VQ9.
Assisted-by: OpenAI Codex
Windows headers define small as char, so the local extent variable
breaks compilation in both MSVC CI configurations. Rename it to
small_extents.
Reproduced the failure with the macro defined and verified that the
same compilation succeeds after the rename. The MinGW cross-compiler
syntax check and full Meson suite pass (274 tests).
Assisted-by: OpenAI Codex
Changing extents during painting could allocate small group surfaces
against the original root and clip, causing out-of-bounds reads and
writes. Keep all session surfaces at the root's extents.
Use the same extents for group clear charges and pixel budget
recharges, so changing the configured rectangle cannot undercount
work on the active image. Document that render clears extents rather
than deferring a mid-session change to the next image.
Adapt the pixel regression from #6450 and check the render lifecycle.
Add an internal test for new and cached group clear charges and
budget recharging, using small buffers.
Reproduced the heap overflow on main under ASan. The budget test
fails with #6450. With this change, both raster test targets pass
under ASan+UBSan and the full Meson suite passes (274 tests).
Assisted-by: OpenAI Codex
Co-authored-by: nussaiba shaikh <nussaibah@bugqore.com>
Saturated int32 extents can round up to 2^31 when converted to float.
Clamp each scaled field before converting back to hb_position_t.
Compute width and height in double relative to the stored, clamped
bearings, preserving the existing formulas when a bearing saturates.
Adapt the COLR clip-box regression from #6459 and cover positive and
negative scales. At default scale, rounding INT32_MAX up to 2^31
leaves a one-unit extent relative to the clamped bearing.
Reproduced the original float-cast-overflow under UBSan. After the
fix, the color, extents, and font-scale API tests pass under UBSan,
and the full Meson test suite passes (273 tests).
Co-authored-by: nussaiba shaikh <nussaibah@bugqore.com>
Assisted-by: OpenAI Codex
Returning false without setting a serializer error treats the CFF
subset as empty and silently drops its outlines. Record an error when
format 1 needs more than 255 encoding ranges so subsetting fails.
Reuse the many-codes fixture to check that 255 ranges still succeed
and 256 ranges fail. The regression fails before the fix.
Testing: meson test -C build (273 passed).
Assisted-by: OpenAI Codex
A format 1 Encoding can give codes to more than 255 glyphs, since
codes may repeat across ranges. When the subset keeps more than 255
of those glyphs, as with retain-gids, plan_subset_encoding() hit
assert (subset_enc_num_codes <= 0xFF).
Choose format 0 only when it can hold the codes, and fail cleanly in
the format 1 serializer instead of truncating nRanges past 255.
Add a test font whose format 1 Encoding covers 768 glyphs, and the
reporter's font to the fuzzing corpus.
Fixes: https://github.com/harfbuzz/harfbuzz/issues/6031
Assisted-by: Claude
Assisted-by: OpenAI Codex
A subroutine can push all four seac operands, return, and leave the
glyph's own endchar to consume them. Treat callsubr and callgsubr
immediately before endchar as possible seac suffixes even when no
subroutine contains endchar.
Add a synthetic CFF1 regression font for the operand-only subroutine
case.
Assisted-by: OpenAI Codex
A subroutine can terminate a glyph with endchar, and dotsection preserves
live operands. Account for both cases when deciding whether a CFF1
charstring can form a seac composite.
Cache whether any subroutine may contain endchar so ordinary fonts keep
the fast trailing-byte check. Skip component closure when all glyphs are
already retained, except when computing reusable accelerator metadata.
Add regressions for endchar in a local subroutine and operands preserved
across dotsection.
Assisted-by: OpenAI Codex
After computing subroutine closure, reuse source charstrings and
subroutines when every retained subroutine keeps its original number.
This avoids re-encoding full identity CFF1 subsets while preserving
the existing pruning behavior when any subroutine is unused.
The full Meson test suite passes (295 passed, 1 skipped).
Assisted-by: OpenAI Codex
Clear flex-depth deltas when they all round to zero and reject unexpected
operators in the absolute-rounding pass. Cover static fractional operands
in a charstring that also contains blends.
Remove command-capture branches made redundant by the full-instancing
control flow.
Testing: meson test -C build (295 passed, one skipped).
Assisted-by: OpenAI Codex
Context format 6 is unavailable when HB_NO_BEYOND_64K is defined, so
do not register its dependency test in that configuration.
Tested with the default test-ot-depend target, an
HB_NO_BEYOND_64K test-ot-depend build, and the full Meson test suite.
Assisted-by: OpenAI Codex
* Don't divide by zero interpolating duplicate trak tracks
TrackData::get_tracking() brackets the requested track value (always
0 when shaping) between entries i and j and interpolates with
(track - t0) / (t1 - t0). The bracketing scan doesn't assume the
entries are sorted or distinct, so two entries that both have track
value 0.0 end with i = 1, j = 0. That skips the exact-match return
and computes 0/0. The NaN reaches hb_font_t::em_multf(), where the
cast to hb_position_t is undefined (UBSan float-cast-overflow at
hb-font.hh:1167); in practice the advance becomes INT_MIN on x86 and
the tracking is dropped on arm64.
Sanitize accepts such a table, so any font with STAT plus this trak
reaches it from hb_shape(); the CoreText font funcs call the same
getter.
Handle t0 == t1 the way TrackTableEntry::interpolate_at() already
handles equal sizes, by averaging the two values.
Added a 108-byte font to the aat-trak shape tests. It fails without
the fix and passes with it. meson test passes on an ASan+UBSan
debug build.
Assisted-by: Claude
* [aat] Pin duplicate-trak test to ot font funcs
The 108-byte test font only carries STAT and trak, with no head,
hhea or hmtx. The ot font funcs give each glyph a 500 advance, but
FreeType reports 1000 and DirectWrite refuses to load the font, so
the ft and directwrite runs of the test disagreed with the expected
output. The test only needs to exercise the trak interpolation,
so pin it to --font-funcs=ot like other minimal-font tests.
Tested with meson test -C build; the shape suites pass with
FreeType enabled.
Assisted-by: Claude
Split long CFF charset runs into format 1 chunks and compare the
resulting size with formats 0 and 2. Previously, any run longer than
256 glyphs forced all ranges to format 2.
This reduces the CFF table for NotoSansSC-Thin.otf by 13,938 bytes
without changing decoded table contents.
Assisted-by: OpenAI Codex
ContextFormat3_6<MediumTypes> (context format 6) stores its input
Coverage offsets as Offset24, but depend() passed them to
context_depend_lookup() cast to HBUINT16, so every input position
after the first decoded the wrong bytes as its offset.
intersects_coverage() then followed that value to a Coverage table
sanitize never checked.
With small offsets the misread value is 0, which points at the
subtable header, and the nested lookup's dependencies are silently
dropped. A crafted rule can instead point the misread offset at bytes
shaped like a large Coverage, and CoverageFormat1_3::intersects() reads
past the end of the GSUB blob (ASan heap-buffer-overflow via
hb_subset_depend_from_face_or_fail).
The other ContextFormat3_6 methods pass coverageZ.arrayZ + 1 as is and
let glyph_data_t pick the width. Do the same here.
ChainContextFormat3 has the same cast but only has a 16-bit
instantiation.
Add a format 6 font and test to test-ot-depend.c; it fails without
the fix. Tested with meson test under ASan+UBSan with
-Dexperimental_api=true.
Assisted-by: Claude