Skip to content

fix out-of-bounds read in normalize_cond_str on unterminated class#691

Open
arshsmith1 wants to merge 1 commit into
GNUAspell:masterfrom
arshsmith1:affix-cond-oob
Open

fix out-of-bounds read in normalize_cond_str on unterminated class#691
arshsmith1 wants to merge 1 commit into
GNUAspell:masterfrom
arshsmith1:affix-cond-oob

Conversation

@arshsmith1

Copy link
Copy Markdown

normalize_cond_str scans the members of a [...] character class looking for the closing ], but the inner loop never checks for the string terminator. When an affix file opens a class and never closes it (say a condition field of [ab), that scan runs off the end of the heap buffer holding the field, which is an out-of-bounds read and a one-byte out-of-bounds write from the min swap a few lines down. The added terminator check reports the unterminated class through the existing invalid_cond path and leaves well-formed conditions alone.

Minimal repro with a two-line affix file (xx_affix.dat):

SET iso8859-1
SFX A Y 1
SFX A 0 s [ab

plus a matching xx.dat containing affix xx, then aspell --lang=xx --data-dir=. --local-data-dir=. --dict-dir=. create master ./xx.rws. An ASan build reports a heap-buffer-overflow in normalize_cond_str at the class scan (affix.cpp:224), reached through AffixMgr::parse_file. With the patch aspell instead prints The condition "[ab" is invalid.

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.

1 participant