mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-19 22:11:04 +01:00
[hb-info] Fix two --list-* crashes/garbage on unusual fonts (#6517)
* [hb-info] Skip unresolvable variation sequences in --list-unicodes _list_unicodes() asserted that every codepoint returned by hb_face_collect_variation_unicodes() also resolves via hb_font_get_variation_glyph(), but the library never guarantees that: collection reads only the cmap format 14 subtable, while lookup additionally requires a nominal cmap mapping for Default UVS ranges and a non-zero glyph for Non-Default UVS mappings. A structurally valid, sanitizer-clean font that lists an unmapped codepoint in a Default UVS range, or glyph 0 in a Non-Default UVS entry, therefore aborted hb-info --list-unicodes/--list-all/--all in any assertion-enabled build (the meson debugoptimized default). Treat a failed lookup as data and skip the sequence instead of asserting. Both library calls behave as documented, and the subsetter relies on collect_variation_unicodes() returning every listed entry, so the fix belongs in the tool. Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-DM9ORF9Z. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * [hb-info] Skip dangling LangSys feature indices in --list-features The script-sensitive path of _list_features() printed a local hb_tag_t that hb_ot_layout_table_get_feature_tags() only writes when the requested index exists. LangSys::sanitize bounds-checks the feature-index array but not its values, so a featureIndex past the end of the FeatureList left the tag uninitialised and hb-info printed stack garbage (NUL bytes under -O2, the previous tag under ASan). Initialise the tag, resolve it at the top of the per-feature loop, and honour the returned count by skipping the entry when it is zero, matching how the shaper ignores such indices. This is a tool-only defect: the library already returns zero tags for the dangling index. Reported by Anthropic's OSS Scanner as ordinary bug ANT-2026-TM7BTKMU. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
8b5d290611
commit
f2fdcdcd4e
1 file changed
+13
-7
+13
-7
@@ -860,9 +860,12 @@ retry:
|
||||
for (hb_codepoint_t u = HB_SET_VALUE_INVALID;
|
||||
hb_set_next (unicodes, &u);)
|
||||
{
|
||||
/* A Default UVS range may list a codepoint that has no nominal
|
||||
* mapping, and a Non-Default UVS mapping may point to glyph 0;
|
||||
* both are collected above but do not resolve to a glyph. */
|
||||
hb_codepoint_t gid = 0;
|
||||
HB_UNUSED bool b = hb_font_get_variation_glyph (font, u, vs, &gid);
|
||||
assert (b);
|
||||
if (!hb_font_get_variation_glyph (font, u, vs, &gid))
|
||||
continue;
|
||||
|
||||
char glyphname[128];
|
||||
hb_font_glyph_to_string (font, gid,
|
||||
@@ -1122,6 +1125,14 @@ retry:
|
||||
|
||||
for (unsigned feature_index = 0; feature_index < feature_count; feature_index++)
|
||||
{
|
||||
hb_tag_t feature_tag = HB_TAG_NONE;
|
||||
unsigned f_count = 1;
|
||||
hb_ot_layout_table_get_feature_tags (face, table_tag,
|
||||
feature_array[feature_index],
|
||||
&f_count, &feature_tag);
|
||||
if (!f_count)
|
||||
continue; /* LangSys references a feature the FeatureList doesn't have. */
|
||||
|
||||
hb_ot_name_id_t label_id;
|
||||
|
||||
hb_ot_layout_feature_get_name_ids (face,
|
||||
@@ -1142,11 +1153,6 @@ retry:
|
||||
|
||||
printf (" ");
|
||||
if (verbose) printf ("Feature: ");
|
||||
hb_tag_t feature_tag;
|
||||
unsigned f_count = 1;
|
||||
hb_ot_layout_table_get_feature_tags (face, table_tag,
|
||||
feature_array[feature_index],
|
||||
&f_count, &feature_tag);
|
||||
printf ("%c%c%c%c", HB_UNTAG (feature_tag));
|
||||
|
||||
if (*name)
|
||||
|
||||
Reference in new issue
Block a user