Skip to content

ly common BUGFIX reject overlong 4-byte UTF-8 sequences - #2618

Merged
michalvasko merged 1 commit into
CESNET:develfrom
affan-arch:utf8-overlong-4byte
Nov 3, 2026
Merged

michalvasko merged 1 commit into
CESNET:develfrom
affan-arch:utf8-overlong-4byte

Conversation

@affan-arch

Copy link
Copy Markdown

ly_getutf8() used 0x1000 as the lower bound for 4-byte sequences instead of 0x10000, so the XML and JSON parsers accepted overlong forms such as F0 81 80 80 (U+1000) or F0 8D A0 80 (a surrogate the 3-byte branch rejects), and since those values are stored with is_utf8 set they skip ly_checkutf8() and get printed back as invalid UTF-8 that lyd_new_term() would have refused and strict parsers like expat choke on; the new cases in types/string.c fail without the fix.

ly_getutf8() accepted 4-byte sequences decoding to 0x1000 - 0xFFFF,
which are overlong forms of 3-byte characters, including the UTF-16
surrogates rejected by the 3-byte branch. The XML and JSON parsers use
it to check values that are then stored with is_utf8 set, so these
sequences were accepted and printed back verbatim, while ly_checkutf8()
used for the other inputs rejects them.
@michalvasko
michalvasko changed the base branch from master to devel November 3, 2026 10:33

@michalvasko michalvasko left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks fine, but change the base branch to devel again.

@michalvasko
michalvasko merged commit d32dbc3 into CESNET:devel Nov 3, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants