From 752bd8a192af209f44dacaf1d3510d0bfc6354b8 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 10 Nov 2018 21:13:13 -0500 Subject: [PATCH] [kerx] Fix Format1 tupleKern sanitization Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11312 Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11305 --- src/hb-aat-layout-kerx-table.hh | 6 +++--- ...case-minimized-hb-shape-fuzzer-5629524117553152 | Bin 0 -> 93 bytes 2 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-shape-fuzzer-5629524117553152 diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh index 3cd80acfd..6b61186a9 100644 --- a/src/hb-aat-layout-kerx-table.hh +++ b/src/hb-aat-layout-kerx-table.hh @@ -262,10 +262,12 @@ struct KerxSubTableFormat1 if (Format1EntryT::performAction (entry)) { + unsigned int tuple_count = MAX (1u, table->header.tuple_count ()); + unsigned int kern_idx = Format1EntryT::kernActionIndex (entry); kern_idx = Types::offsetToIndex (kern_idx, &table->machine, kernAction.arrayZ); const FWORD *actions = &kernAction[kern_idx]; - if (!c->sanitizer.check_array (actions, depth)) + if (!c->sanitizer.check_array (actions, depth * tuple_count)) { depth = 0; return false; @@ -276,8 +278,6 @@ struct KerxSubTableFormat1 /* From Apple 'kern' spec: * "Each pops one glyph from the kerning stack and applies the kerning value to it. * The end of the list is marked by an odd value... */ - unsigned int tuple_count = table->header.tuple_count (); - tuple_count = tuple_count ? tuple_count : 1; bool last = false; while (!last && depth--) { diff --git a/test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-shape-fuzzer-5629524117553152 b/test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-shape-fuzzer-5629524117553152 new file mode 100644 index 0000000000000000000000000000000000000000..01ca51737da80a826de509165a8f733dcc0816cc GIT binary patch literal 93 zcmZQzWME)mQ~-nQ)S?Oy11O>b5kZhZF_5?_Pz0