Skip to content

fix out-of-bounds read in DecodeNormLookup::decode#686

Open
arshsmith1 wants to merge 1 commit into
GNUAspell:masterfrom
arshsmith1:convert-norm-oob-read
Open

fix out-of-bounds read in DecodeNormLookup::decode#686
arshsmith1 wants to merge 1 commit into
GNUAspell:masterfrom
arshsmith1:convert-norm-oob-read

Conversation

@arshsmith1

Copy link
Copy Markdown

In common/convert.cpp, DecodeNormLookup::decode walks the normalization output with the guard ret.to[i] && i < E::max_to, so it dereferences ret.to[i] before the index is bounds-checked. When a decoded entry fills all three output slots with non-zero values, i reaches max_to and the loop reads ret.to[max_to], one Uni16 past the end of the max_to-sized to[] array (ToUniNormEntry::to is Uni16 to[3]). This path is reached when normalization is enabled and a to_uni norm form is selected, decoding untrusted input text.

Reorder the two conditions so the bounds test short-circuits first, matching the three sibling loops in EncodeNormLookup a few lines down that already read as i < E::max_to && ret.to[i]. Keeping the check on the same side as its siblings is the least surprising place for it.

@kevina kevina requested review from kevina and removed request for kevina July 6, 2026 18:33
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