fix heap overflow in SfxEntry::add when strip exceeds word length#687
Open
arshsmith1 wants to merge 1 commit into
Open
fix heap overflow in SfxEntry::add when strip exceeds word length#687arshsmith1 wants to merge 1 commit into
arshsmith1 wants to merge 1 commit into
Conversation
Member
|
Please open an issue with a simple test case that demonstrates the problem. |
Author
|
Done, opened #688 with a minimal test case. It's a two-file affix dir plus iso-8859-1.cset, and |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SfxEntry::add checks the suffix conditions against orig_word but computes the copy length from word, which can be shorter once a cross-product prefix has already stripped it. When word is shorter than the suffix strip, word.size - stripl wraps and the following buf.alloc/memcpy run with a negative length, so an affix file with a cross-product prefix that shortens the word plus a suffix whose strip is longer overflows the heap during expand (for example the line aaaaac/AB with PFX A stripping aaaaa and SFX B stripping aaac). Bail out with an empty result when word can't hold the strip, matching the guard PfxEntry::add and SfxEntry::applicable already use.