Skip to content

Conversation

cxw42
Copy link
Contributor

@cxw42 cxw42 commented Jan 14, 2023

The inner iterator in parse_ml_literal_string() and parse_literal_string() was being reset to an iterator into a different region of memory. Fix that by using the same iterator initialization as is used in the parse*_basic_string().

Fixes #199.

Demonstration of the fix:
poc2.zip

$ unzip poc2.zip
$ g++ -fsanitize=address -g -o issue199 issue199.cpp && ./issue199 poc.toml ; echo $?
[error] parse_ml_basic_string: invalid utf8 sequence found
 --> poc.toml
   |
 1 | str3 = 'C:\highway\to\�he\danger\zone'
   |                       ^--- here
1

cxw42 added 2 commits January 14, 2023 18:32
When creating the inner iterator, make sure it points into the same
vector as the outer iterator.  Otherwise, attempts to reset the iterator
wind up causing it to read out-of-bounds.

Fixes ToruNiina#199.
Fix the same out-of-bounds read as in parse_literal_string().
@ToruNiina
Copy link
Owner

LGTM. Thank you!

@cxw42 cxw42 deleted the issue199-nonutf-string branch April 10, 2023 01:46
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.

Heap buffer overflow (out-of-bounds read) in toml::detail::location::reset()
2 participants