From 8abfd0d16ebf8169da5ee16195df2c801bbefb5c Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 18 Oct 2026 18:01:11 -0600 Subject: [PATCH] [subset] Reject failed glyph sets before allocating flat maps (#6409) An allocation failure can leave out-of-range glyph IDs in the GSUB set because subsequent range deletions are skipped. Building the flat glyph map from that set can then request several gigabytes before the set's error state is checked. Reject an errored GSUB glyph set before sizing the flat map, and add the minimized fuzzer testcase to the regression corpus. Tested with the full Meson suite (292 passed, one skipped) and 100 reproducer runs under ASan/UBSan with failing allocations enabled. Fixes: https://oss-fuzz.com/testcase-detail/5574495277219840 Assisted-by: OpenAI Codex --- src/hb-subset-plan.cc | 3 +++ ...se-minimized-hb-subset-fuzzer-5574495277219840 | Bin 0 -> 213 bytes 2 files changed, 3 insertions(+) create mode 100644 test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5574495277219840 diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc index 56dfd8692..e6b425b10 100644 --- a/src/hb-subset-plan.cc +++ b/src/hb-subset-plan.cc @@ -528,6 +528,9 @@ _create_glyph_map_gsub (const hb_set_t* glyph_set_gsub, hb_map_t* out, hb_vector_t* out_flat) { + if (unlikely (glyph_set_gsub->in_error ())) + return false; + hb_codepoint_t max_gid = HB_SET_VALUE_INVALID; hb_set_previous (glyph_set_gsub, &max_gid); unsigned flat_size = max_gid == HB_SET_VALUE_INVALID ? 0 : max_gid + 1; diff --git a/test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5574495277219840 b/test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5574495277219840 new file mode 100644 index 0000000000000000000000000000000000000000..df04966ade07bb3956047c88801312849a4c9b4f GIT binary patch literal 213 zcmZQzWME)mS5RPJR8UCHO)O9V0-#6@h(-ec75*dfV9fs@!T(?qB81F_DMHY>i4`#O qIY6R7dzcuQfg}Ti2$XNdz=Kc^6bHFZ0f<$!fx_6FfKZKK{RaT%yCUcS literal 0 HcmV?d00001