Regex: Fix integer overflow in expression parsing.

See: https://oss-fuzz.com/v2/testcase-detail/6189682419302400?noredirect=1
This commit is contained in:
jzmaddock
2017-10-07 09:47:19 +01:00
parent 289ce86488
commit 881a157243
2 changed files with 8 additions and 0 deletions

View File

@ -2070,6 +2070,11 @@ insert_recursion:
fail(regex_constants::error_perl_extension, m_position - m_base, "An invalid or unterminated recursive sub-expression.");
return false;
}
if ((std::numeric_limits<boost::intmax_t>::max)() - m_mark_count < v)
{
fail(regex_constants::error_perl_extension, m_position - m_base, "An invalid or unterminated recursive sub-expression.");
return false;
}
v += m_mark_count;
goto insert_recursion;
case regex_constants::syntax_dash: