Files
harfbuzz/src
Behdad EsfahbodandClaude Opus 4.8 60bd82dcb4 [subset] Bound cmap per-record unicode set collection
When rewriting cmap, the subsetter built one hb_set_t of covered code
points per encoding record. SubtableUnicodesCache keyed those sets by
the record's own offset and collected each with num_glyphs = UINT_MAX,
so a font with many records sharing one full-range format 12 subtable
built one ~1.1M-code-point set per record: ~41 s of CPU, or ~2.1 GB of
memory for a 96 KB input, with nothing but the record count (bounded
only by the sanitizer) limiting the work.

Three changes bound it, all matching how nearby cmap code already works:

 1. Key cached_unicodes by record->subtable, so records sharing a
    subtable share one set (both set_for overloads).
 2. Give the cache a num_glyphs member and collect with it instead of
    UINT_MAX, as the cmap accelerator already does for
    hb_face_collect_unicodes; cmap::serialize fills it from
    plan->source->get_num_glyphs() and create_filled_cache() takes it
    as a parameter, passed as face->get_num_glyphs() for
    hb_subset_preprocess.
 3. Process only the first encoding record of each (platformID,
    encodingID) pair in both cmap::serialize and create_filled_cache
    (variation-selector records exempt). Lookup already sees one record
    per pair and EncodingRecord::copy links later records of a format to
    the first serialized subtable, so this bounds both the number of
    sets built and the _can_drop walk regardless of how many records a
    malformed font repeats, independent of whether they share a subtable.

No public API or ABI change. Output is unchanged for well-formed fonts:
the plan's unicodes are already restricted to gids below num_glyphs, and
valid fonts never repeat a (platformID, encodingID) pair. The attached
reproducer's hostile fonts drop from ~41 s / 2.1 GB to ~0 s / 12 MiB
with byte-identical output.

Adds test_subset_cmap_shared_subtable_many_records and
test_subset_cmap_repeated_encoding_records to
test/api/test-subset-cmap.c.

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

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-08 14:36:19 -06:00
..
2026-08-12 18:27:23 -06:00
2024-03-30 02:20:21 +02:00
2026-07-31 04:31:26 +03:00
2026-07-31 04:31:26 +03:00
…
2025-10-17 15:23:05 -06:00
2025-03-12 23:56:52 -06:00
2023-02-21 18:07:53 +02:00
2026-11-04 23:03:36 +02:00
2026-09-21 00:41:07 +03:00
2026-09-21 00:41:07 +03:00
2026-09-21 00:41:07 +03:00
2026-10-16 00:19:21 +03:00
2025-03-24 00:33:53 +02:00
2025-09-15 23:56:25 -06:00
…
…
2026-04-20 05:10:48 +02:00
2026-04-20 05:10:48 +02:00
2024-10-27 16:14:53 -07:00
…
2026-10-22 17:05:31 +03:00
2023-08-25 07:51:05 -06:00
2023-06-03 14:56:47 -06:00
2025-04-08 01:58:10 -06:00
2025-08-07 22:38:58 -06:00
2026-07-31 17:49:40 +03:00
2026-07-31 17:49:40 +03:00
2023-02-11 23:52:58 +02:00
2025-08-07 22:38:58 -06:00
2026-03-19 00:45:24 +02:00
2024-04-16 17:10:09 -06:00
2026-07-31 04:31:26 +03:00
2026-09-21 00:41:07 +03:00
2026-04-18 10:58:44 -06:00
2026-09-21 00:41:07 +03:00
2026-08-26 22:27:05 +03:00
2026-08-19 16:00:05 -06:00
2025-07-23 21:39:23 +03:00
2024-08-23 08:58:50 -06:00
2026-07-31 17:49:40 +03:00
2025-01-11 18:13:18 +02:00
2026-07-30 12:00:47 -06:00
2026-10-01 16:27:20 -06:00
2026-07-31 17:49:40 +03:00
…
2023-04-27 00:48:00 +02:00
2026-04-20 01:29:49 +02:00
2026-11-04 23:03:36 +02:00
2025-03-07 18:19:29 -07:00
2026-08-12 18:33:09 -06:00
…
2026-06-05 13:44:29 +02:00
2023-01-12 17:04:24 -07:00