The standalone WebAssembly Graphite shaper mirrors the native backend
and had the same unchecked coordinate, cluster, and pen arithmetic.
Clamp backend values and saturate its signed position accumulation.
This is part of the complete position-overflow fix for issue #6151.
Testing: g++ -std=c++17 -Isrc -fsyntax-only src/wasm/graphite/shape.cc
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
CFF2 instancing consumes full-range glyph extents and untrusted
variation deltas while rebuilding font and glyph metrics. Saturate
extent endpoints and side-bearing differences and keep advance
accumulation widened through its final UFWORD clamp.
This is part of the complete position-overflow fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
The MATH kern search comparator multiplied and subtracted signed
positions, which overflows for full-range correction heights. Compare
the values directly while respecting the scale direction.
This is part of the complete position-overflow fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
The Fontations callbacks used ordinary Rust arithmetic for vertical
metrics and glyph extents. Use saturating operations for sequential
updates and widened arithmetic for the multi-term vertical-origin
fallback.
This is part of the complete position-overflow fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
Fallback cap-height and em-size formulas multiply or combine
full-range glyph positions and font scales. Widen and clamp those
formulas and saturate the underline-offset negation.
This is part of the complete position-overflow fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
Variable glyf and CFF outlines can produce floating bounds outside the
signed position range. Keep rounded endpoints widened, clamp bearings,
and clamp endpoint differences before scaling the glyph extents.
This is part of the complete position-overflow fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
Bitmap strike scaling converts attacker-controlled image dimensions and
offsets to glyph positions through unchecked float and mixed-sign
arithmetic. Widen the sbix coordinate sum and clamp scaled sbix and
CBDT extents.
This is part of the complete position-overflow fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
The Cairo adapter accumulated full-range glyph positions in signed
HarfBuzz positions before converting them to doubles. Accumulate and
negate in double precision instead, and clamp the scale passed back to
the HarfBuzz font.
This is part of the complete position-overflow fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
Buffer serialization accumulates advances and adds offsets in signed
positions even when advances are omitted from the output. Saturate the
pen and final-coordinate arithmetic in both text and JSON formats.
This is part of the complete position-overflow fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
FreeType exposes full-width fixed-point metrics which were narrowed or
combined before reaching HarfBuzz positions. Widen the calculations,
clamp advances, origins, kerning, extents, and font metrics, and avoid
negating the minimum fixed-point value.
This is part of the complete position-overflow fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
Vertical-origin caching normalizes positions by scale sign, and the
extents fallback combines several full-width metrics. Saturate sign and
font-advance operations and widen the fallback centering formula.
This is part of the complete position-overflow fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
OpenType fallback and variable advances can span the full position
range, while non-variable table values are unsigned. Clamp unscaled
values, use the full-range scalers, and saturate vertical negation and
font-extents subtraction.
This is part of the complete position-overflow fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
Some variable-font and backend metrics are already full-width signed
positions rather than 16-bit font values. Add explicit full-range
scalers which preserve the fixed-point fast path for ordinary values
and clamp wider results through the existing floating scaler.
This is part of the complete position-overflow fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
Uniscribe scales scratch advances and offsets through unchecked
floating-point-to-position conversions. Clamp each result and negate
backward offsets after widening them to double.
This is part of the complete position-overflow fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
DirectWrite returns floating-point advances and offsets which were
stored and scaled through unchecked integer conversions. Clamp the
scratch values and final scaled positions, and negate RTL offsets in
floating point.
This is part of the complete position-overflow fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
DirectWrite metrics are wider than the signed 16-bit values accepted by
the normal font-space scaler, and extents combine mixed signed and
unsigned fields. Preserve the common scaling path, clamp wider values,
and saturate the resulting extents arithmetic.
This is part of the complete position-overflow fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
CoreText font callbacks convert floating-point advances, origins,
extents, and metrics directly to signed positions. Clamp conversions,
widen extents arithmetic, and avoid negating an integer scale first.
This is part of the complete position-overflow fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
CoreText shaping converts unbounded floating-point run positions and
font callback results to signed glyph positions. Clamp those
conversions and saturate fallback advance and origin arithmetic.
This is part of the complete position-overflow fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
Graphite coordinates and cluster advances can exceed the position
range after scaling or accumulation. Clamp backend-produced values and
saturate cluster and pen arithmetic before storing glyph positions.
This is part of the complete position-overflow fix for issue #6151.
Testing: ninja -C build-graphite2 src/libharfbuzz.so.0.61431.0
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
Glyph extents can span the full position range supplied by a callback.
Scale widened rectangle endpoints and clamp the rounded result instead
of narrowing inputs and relying on overflowing position arithmetic.
This is part of the complete position-overflow fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
Synthetic emboldening updates callback-provided font extents with
unchecked position arithmetic. Saturate the sign adjustment and each
extents update.
This is part of the complete position-overflow fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
Synthetic slanting and emboldening update callback-provided glyph
extents with unchecked position arithmetic. Widen and clamp the slant
geometry, then saturate sequential emboldening updates.
This is part of the complete position-overflow fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
AAT kerx format 4 derives mark offsets by subtracting callback or scaled
anchor coordinates. Saturate each coordinate difference so extreme
origins and public font scales cannot overflow.
This is part of the complete position-overflow fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
The optional split-kern path applies a ValueRecord to a temporary
position and redistributes it across the pair. Saturate every destination
update and clamp the one three-term expression after widening.
This closes the final unchecked GPOS position path for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
Bulk origin fallback converts between horizontal and vertical origins
by adding advances and ascenders. Saturate those temporary position
updates before applying them to the buffer.
This is part of the complete position-overflow fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
Synthetic emboldening updates callback-provided glyph advances and
origins. Saturate scalar and bulk results, including strength negation
for negative font scales.
This keeps public callback extremes from reintroducing position overflow
as part of the complete fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
Computing synthetic emboldening strength could negate INT_MIN through
abs() and convert an out-of-range float to int32_t. Use floating-point
absolute value and clamp the rounded result to a valid position.
This is part of the complete position-overflow fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
Font scaling can produce values outside hb_position_t at extreme public
font scales. Clamp design-unit, floating-point, and parent-font scaling
results before returning them to positioning code.
This ensures later saturating additions receive valid position operands
as part of the complete fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
Arabic stch justification accumulates word and tile widths, then walks
repeated tiles to assign offsets. Saturate those hb_position_t values
and clamp the computed overlap from its 64-bit intermediate.
This is part of the complete position-overflow fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
Fallback cluster positioning accumulates advances into mark offsets and
partitions ligature extents. Saturate the position accumulators and use
bounded 64-bit intermediates for the component formulas.
This completes the tracked fallback-shaping arithmetic covered by
Chromium's sanitizer exemption for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
Fallback mark positioning combines several glyph extents and updates a
running attachment box. Use widened, clamped formulas where cancellation
matters and saturating arithmetic for sequential box updates.
Keep the original integer-division rounding behavior. This fixes the
remaining arithmetic in Chromium's fallback sanitizer exemption as
part of issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
Provide an always-inline int64_t overload of hb_clamp_to for cold
position formulas that need wider intermediate arithmetic while
preserving integer division and rounding semantics.
Add boundary tests. This supports the complete position-overflow fix
for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
Fallback mark positioning can preserve placement while zeroing mark
advances. Saturate that offset adjustment instead of subtracting
unchecked hb_position_t values.
This is part of the complete position-overflow fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
Font-origin fallback code centralizes position updates in add, subtract,
and signed offset helpers. Make those helpers saturating, including the
INT_MIN case that previously overflowed while multiplying by -1.
This is part of the complete position-overflow fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
Zeroing mark widths first moves their advances into the offsets. Use
saturating subtraction for that position update so extreme font scales
cannot overflow before GPOS is applied.
This is part of the complete position-overflow fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
Glyph normalization accumulates cluster advances, moves offsets, and
then redistributes the result after sorting. Saturate each hb_position_t
update so very large clusters cannot overflow during normalization.
This is part of the complete position-overflow fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
AAT tracking adds the selected tracking value to the first glyph of
each grapheme. Saturate horizontal and vertical advance updates so an
extreme scale or repeated application cannot overflow hb_position_t.
This is part of the complete position-overflow fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
AAT kerx state-machine actions add scaled values to glyph advances and
offsets, including cross-stream attachments. Saturate each stored
position update to avoid signed overflow on repeated actions.
This is part of the complete position-overflow fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
Legacy kern application split a kerning value across two glyphs with
unchecked additions to advances and offsets. Saturate those updates and
remove the signed-overflow sanitizer exemption from the function.
The exemption macro has no remaining tracked users, so remove it as
well. This is part of the complete fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
Applying a synthetic slant combines a floating-point displacement with
an existing hb_position_t offset. Clamp the final result so extreme
slants cannot overflow the float-to-integer conversion or the position
sum.
This is part of the complete position-overflow fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
Cursive attachment combines rounded anchors with existing advances and
offsets, then may negate the cross-stream displacement. Clamp the
floating-point conversions and saturate the integer arithmetic at each
stored hb_position_t result.
This is part of the complete position-overflow fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
Reversing a cursive attachment chain negates the child's cross-stream
offset. Saturate that negation so INT_MIN produces INT_MAX instead of
signed-overflow undefined behavior.
This is part of the complete position-overflow fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
Add an always-inline saturating negation for position values that can
reach INT_MIN. Also require the floating-point clamp helper to inline,
matching the add and subtract helpers used throughout shaping.
Extend the boundary tests for both helpers. This supports the complete
position-overflow fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
ValueRecord placement, advance, and device adjustments all update
hb_position_t fields. Saturate those additions and subtractions so
large scales or repeated lookups cannot invoke signed overflow.
The helper keeps the common path to one arithmetic instruction and a
not-taken overflow branch, which limits the cost in this hot path.
This is part of the complete fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
Deferred mark and cursive attachment propagation combines offsets with
the advances between attached glyphs. Use saturating arithmetic for
each position update instead of relying on signed overflow behavior.
This removes the historical overflow from the function that issue
#6151 moved out of Chromium's sanitizer exemption.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
A mark can resolve its cross-stream position through a cursive
attachment chain. Saturate that accumulation so an overlong chain
cannot overflow hb_position_t while applying GPOS.
This is part of the position-overflow fix for issue #6151.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
Mark-to-mark attachment can accumulate an unbounded cross-direction
offset. Clamp anchor conversion and saturate the immediate addition so
overlong mark clusters stop at hb_position_t limits instead of invoking
signed-overflow undefined behavior.
Add a regression for issue #6151 using 35,000 combining marks.
Testing: meson test -C build --print-errorlogs
Assisted-by: Codex <codex@openai.com>
Provide always-inline signed add and subtract helpers for position
arithmetic. Compiler overflow builtins reduce the common path to one
arithmetic instruction and a not-taken overflow branch.
This is the foundation for fixing the position overflow reported in
issue #6151.
Assisted-by: Codex <codex@openai.com>
SubsetGlyph stores borrowed slices into the source glyf table. Faces
created with a table callback may return a fresh blob on each request,
so destroying the population accelerator left those slices dangling
before they were serialized.
Retain the exact glyf blob through serialization. Exercise this path
by making the existing create-for-tables test return copied blobs.
Reported by WinD39 - Huynh Dinh Vu.
Fixes: https://issues.chromium.org/issues/536584255
Assisted-by: OpenAI Codex <codex@openai.com>