Skip to content

Adjust local_name_length when stripping prefix in HTML5 attribute parser - #25840

Open
hohphu8 wants to merge 1 commit into
php:PHP-8.4from
hohphu8:fix-dom-html5-attr-local-name-len
Open

hohphu8 wants to merge 1 commit into
php:PHP-8.4from
hohphu8:fix-dom-html5-attr-local-name-len

Conversation

@hohphu8

@hohphu8 hohphu8 commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

In lexbor_libxml2_bridge_convert() (ext/dom/html5_parser.c), when converting a prefixed foreign HTML5 attribute (attr->node.prefix set, e.g. xlink:href or xml:lang), local_name is advanced past the ':' separator without reducing local_name_length by the skipped prefix length. The unadjusted local_name_length is then passed to xmlDictLookup(doc->dict, local_name, local_name_length), causing it to read past the end of the local name string (up to a few bytes past u.short_str inside lxb_dom_attr_data_t).

This subtracts the skipped byte count (pos + 1 - local_name) from local_name_length alongside advancing local_name.

Verified clean build and ext/dom/tests/modern/ passing on PHP-8.4 (Debug + ZTS) and master (ASan+UBSan). No userland-visible failure has been observed; the issue was identified through source inspection.

Note: Identified through AI-assisted source inspection, then independently reviewed, built, and tested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant