mirror of
https://github.com/boostorg/regex.git
synced 2025-07-15 05:16:37 +02:00
Change POSIX API's so regcomp doesn't check for magic value and read potentially uninitialized memory.
See https://svn.boost.org/trac/boost/ticket/11472.
This commit is contained in:
@ -68,9 +68,6 @@ typedef boost::basic_regex<char, c_regex_traits<char> > c_regex_type;
|
|||||||
|
|
||||||
BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA* expression, const char* ptr, int f)
|
BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA* expression, const char* ptr, int f)
|
||||||
{
|
{
|
||||||
if(expression->re_magic != magic_value)
|
|
||||||
{
|
|
||||||
expression->guts = 0;
|
|
||||||
#ifndef BOOST_NO_EXCEPTIONS
|
#ifndef BOOST_NO_EXCEPTIONS
|
||||||
try{
|
try{
|
||||||
#endif
|
#endif
|
||||||
@ -78,13 +75,13 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA* expression, const char
|
|||||||
#ifndef BOOST_NO_EXCEPTIONS
|
#ifndef BOOST_NO_EXCEPTIONS
|
||||||
} catch(...)
|
} catch(...)
|
||||||
{
|
{
|
||||||
|
expression->guts = 0;
|
||||||
return REG_ESPACE;
|
return REG_ESPACE;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if(0 == expression->guts)
|
if(0 == expression->guts)
|
||||||
return REG_E_MEMORY;
|
return REG_E_MEMORY;
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
// set default flags:
|
// set default flags:
|
||||||
boost::uint_fast32_t flags = (f & REG_PERLEX) ? 0 : ((f & REG_EXTENDED) ? regex::extended : regex::basic);
|
boost::uint_fast32_t flags = (f & REG_PERLEX) ? 0 : ((f & REG_EXTENDED) ? regex::extended : regex::basic);
|
||||||
expression->eflags = (f & REG_NEWLINE) ? match_not_dot_newline : match_default;
|
expression->eflags = (f & REG_NEWLINE) ? match_not_dot_newline : match_default;
|
||||||
|
@ -78,9 +78,6 @@ typedef boost::basic_regex<wchar_t, c_regex_traits<wchar_t> > wc_regex_type;
|
|||||||
|
|
||||||
BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wchar_t* ptr, int f)
|
BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wchar_t* ptr, int f)
|
||||||
{
|
{
|
||||||
if(expression->re_magic != wmagic_value)
|
|
||||||
{
|
|
||||||
expression->guts = 0;
|
|
||||||
#ifndef BOOST_NO_EXCEPTIONS
|
#ifndef BOOST_NO_EXCEPTIONS
|
||||||
try{
|
try{
|
||||||
#endif
|
#endif
|
||||||
@ -88,13 +85,13 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wcha
|
|||||||
#ifndef BOOST_NO_EXCEPTIONS
|
#ifndef BOOST_NO_EXCEPTIONS
|
||||||
} catch(...)
|
} catch(...)
|
||||||
{
|
{
|
||||||
|
expression->guts = 0;
|
||||||
return REG_ESPACE;
|
return REG_ESPACE;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if(0 == expression->guts)
|
if(0 == expression->guts)
|
||||||
return REG_E_MEMORY;
|
return REG_E_MEMORY;
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
// set default flags:
|
// set default flags:
|
||||||
boost::uint_fast32_t flags = (f & REG_PERLEX) ? 0 : ((f & REG_EXTENDED) ? wregex::extended : wregex::basic);
|
boost::uint_fast32_t flags = (f & REG_PERLEX) ? 0 : ((f & REG_EXTENDED) ? wregex::extended : wregex::basic);
|
||||||
expression->eflags = (f & REG_NEWLINE) ? match_not_dot_newline : match_default;
|
expression->eflags = (f & REG_NEWLINE) ? match_not_dot_newline : match_default;
|
||||||
|
Reference in New Issue
Block a user