mirror of
https://github.com/boostorg/regex.git
synced 2025-07-21 16:22:43 +02:00
de-fuzz: need to fail when a named recursive subexpression refers to an invalid name.
This commit is contained in:
@ -801,50 +801,57 @@ void basic_regex_creator<charT, traits>::fixup_recursions(re_syntax_base* state)
|
|||||||
//
|
//
|
||||||
idx = m_pdata->get_id(static_cast<int>(idx));
|
idx = m_pdata->get_id(static_cast<int>(idx));
|
||||||
}
|
}
|
||||||
while(p)
|
if(idx < 0)
|
||||||
{
|
{
|
||||||
if((p->type == syntax_element_startmark) && (static_cast<re_brace*>(p)->index == idx))
|
ok = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while(p)
|
||||||
{
|
{
|
||||||
//
|
if((p->type == syntax_element_startmark) && (static_cast<re_brace*>(p)->index == idx))
|
||||||
// We've found the target of the recursion, set the jump target:
|
|
||||||
//
|
|
||||||
static_cast<re_jump*>(state)->alt.p = p;
|
|
||||||
ok = true;
|
|
||||||
//
|
|
||||||
// Now scan the target for nested repeats:
|
|
||||||
//
|
|
||||||
p = p->next.p;
|
|
||||||
int next_rep_id = 0;
|
|
||||||
while(p)
|
|
||||||
{
|
{
|
||||||
switch(p->type)
|
//
|
||||||
{
|
// We've found the target of the recursion, set the jump target:
|
||||||
case syntax_element_rep:
|
//
|
||||||
case syntax_element_dot_rep:
|
static_cast<re_jump*>(state)->alt.p = p;
|
||||||
case syntax_element_char_rep:
|
ok = true;
|
||||||
case syntax_element_short_set_rep:
|
//
|
||||||
case syntax_element_long_set_rep:
|
// Now scan the target for nested repeats:
|
||||||
next_rep_id = static_cast<re_repeat*>(p)->state_id;
|
//
|
||||||
break;
|
|
||||||
case syntax_element_endmark:
|
|
||||||
if(static_cast<const re_brace*>(p)->index == idx)
|
|
||||||
next_rep_id = -1;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if(next_rep_id)
|
|
||||||
break;
|
|
||||||
p = p->next.p;
|
p = p->next.p;
|
||||||
}
|
int next_rep_id = 0;
|
||||||
if(next_rep_id > 0)
|
while(p)
|
||||||
{
|
{
|
||||||
static_cast<re_recurse*>(state)->state_id = next_rep_id - 1;
|
switch(p->type)
|
||||||
}
|
{
|
||||||
|
case syntax_element_rep:
|
||||||
|
case syntax_element_dot_rep:
|
||||||
|
case syntax_element_char_rep:
|
||||||
|
case syntax_element_short_set_rep:
|
||||||
|
case syntax_element_long_set_rep:
|
||||||
|
next_rep_id = static_cast<re_repeat*>(p)->state_id;
|
||||||
|
break;
|
||||||
|
case syntax_element_endmark:
|
||||||
|
if(static_cast<const re_brace*>(p)->index == idx)
|
||||||
|
next_rep_id = -1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(next_rep_id)
|
||||||
|
break;
|
||||||
|
p = p->next.p;
|
||||||
|
}
|
||||||
|
if(next_rep_id > 0)
|
||||||
|
{
|
||||||
|
static_cast<re_recurse*>(state)->state_id = next_rep_id - 1;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
p = p->next.p;
|
||||||
}
|
}
|
||||||
p = p->next.p;
|
|
||||||
}
|
}
|
||||||
if(!ok)
|
if(!ok)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user