Skip to content

Conversation

@albarrentine
Copy link
Contributor

Reviewed and fixed all points where utf8proc_iterate is called and may return an error which can cause the iteration not to make forward progress. This includes fixing a bug where injecting invalid UTF-8 through a series of HTML-encoded codepoints can cause the C library to hang. Note: we're not fixing all the garbage encoding in the world, so if encoding is bad the output of expand_address may not be useful but it won't hang. Fixes #448

…lled and may return an error which can cause the iteration not to make forward progress. This includes fixing a bug where injecting invalid UTF-8 through a series of HTML-encoded codepoints can cause the C library to hang. Note: we're not fixing all the garbage encoding in the world, so if encoding is bad the output of expand_address may not be useful but it won't hang. Fixes #448
@albarrentine albarrentine merged commit fe64076 into master Jul 2, 2025
4 checks passed
Comment on lines 737 to +738
log_warn("transliterator \"%s\" does not exist in trie\n", trans_name);
if (allocated_trans_name) free(trans_name);

Choose a reason for hiding this comment

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

Is it a double-free here? trans_name has already been freed on line 718.

The usage of trans_name in log_warn may also be a use-after-free if it is strdup-ed and then freed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, good catch, hotfixing that by just removing 718 so it's effectively moved to the end of the function. The purpose of adding it in all the other places was to avoid a segfault in the log_warn line.

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.

expand_address hangs with certain strings, with invalid UTF-8 warnings

3 participants