Files
harfbuzz/src/graph
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
..