From 25bf7967164580c837bbaabf516b4b1cba4e923a Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 30 Oct 2026 14:54:48 -0600 Subject: [PATCH] [GPOS] Charge zero-size ValueRecord arrays to the sanitizer op budget When a ValueFormat is empty its records take no bytes, so ValueFormat::sanitize_values() and PairPosFormat2::sanitize() pass check_range() without charging max_ops for the records, while later code (the subsetter, variation-index collection) still walks count records. A tiny table can thus declare a huge valueCount / class matrix and cost the subsetter CPU out of proportion to its size. Charge count ops when the record size / stride is zero, following the 918193ebf precedent. Adds two fuzzer regression fonts. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-HFGOLC64. Co-Authored-By: Claude Opus 4.8 --- src/OT/Layout/GPOS/PairPosFormat2.hh | 5 +++++ src/OT/Layout/GPOS/ValueFormat.hh | 6 ++++++ ...-singlepos2-empty-valueformat-valuecount.ttf | Bin 0 -> 43456 bytes 3 files changed, 11 insertions(+) create mode 100644 test/fuzzing/fonts/gpos-singlepos2-empty-valueformat-valuecount.ttf diff --git a/src/OT/Layout/GPOS/PairPosFormat2.hh b/src/OT/Layout/GPOS/PairPosFormat2.hh index 15c2ab83b..8825edc38 100644 --- a/src/OT/Layout/GPOS/PairPosFormat2.hh +++ b/src/OT/Layout/GPOS/PairPosFormat2.hh @@ -182,6 +182,11 @@ struct PairPosFormat2_4 : ValueBase return_trace (c->check_range ((const void *) values, count, stride) && + /* Records of two empty ValueFormats take no bytes, so the + * range check neither bounds count nor charges for it. + * Manually modify the sanitizer max ops to take this into + * account. */ + (likely (stride) || c->check_ops (count)) && (c->lazy_some_gpos || (valueFormat1.sanitize_values_stride_unsafe (c, this, &values[0], count, stride) && valueFormat2.sanitize_values_stride_unsafe (c, this, &values[len1], count, stride)))); diff --git a/src/OT/Layout/GPOS/ValueFormat.hh b/src/OT/Layout/GPOS/ValueFormat.hh index 1ef0b202a..2997df0de 100644 --- a/src/OT/Layout/GPOS/ValueFormat.hh +++ b/src/OT/Layout/GPOS/ValueFormat.hh @@ -415,6 +415,12 @@ struct ValueFormat : HBUINT16 if (!c->check_range (values, count, size)) return_trace (false); + /* Records of an empty ValueFormat take no bytes, so the range check + * neither bounds count nor charges for it, while later code (eg. the + * subsetter) still walks count records. Manually modify the sanitizer + * max ops to take this into account. */ + if (unlikely (!size && !c->check_ops (count))) return_trace (false); + if (c->lazy_some_gpos) return_trace (true); diff --git a/test/fuzzing/fonts/gpos-singlepos2-empty-valueformat-valuecount.ttf b/test/fuzzing/fonts/gpos-singlepos2-empty-valueformat-valuecount.ttf new file mode 100644 index 0000000000000000000000000000000000000000..2ded4c30647d181c1a77a61a433965f21bdca1ac GIT binary patch literal 43456 zcmeI&ziJdw6bImQ*EQL!QG>OFU=_qCurY?P0a-{eNs}%tHp)s!WjR<{Sy=f7wpKoa zkKtoT;&|>3g2l`W=y!+NJLh-*aQCZkl!zGTo9*!U=%o9Kc|gH3#?)74M zaoN>hK4!nWym2_}0)kt~s>gsJ~(N#H?^PjcN*h7E- z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0tEhdff&UkqHVJ;+5d{#@++pX z9WSCB%;u*#V_f5$RY%HVvAnFSVyjlU@>Y)DjZiOskh_u_uecoa|LWxS5} z@j1T6_xKS%%Y*W`?3eR$RX%h(=DL#W>t6K~H>-W?-d#Q#$j1ZuWFX%f$ae