mirror of
https://github.com/boostorg/regex.git
synced 2025-07-30 04:27:22 +02:00
fix integer overflow when parsing Perl-extended named backrefs
This commit is contained in:
54
test/issue245.cpp
Normal file
54
test/issue245.cpp
Normal file
@ -0,0 +1,54 @@
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "test_macros.hpp"
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
// invalid because \k-- is an unterminated token
|
||||
{
|
||||
char const strdata[] = "\\k--00000000000000000000000000000000000000000000000000000000009223372036854775807\xff\xff\xff\xff\xff\xff\xff\xef""99999999999999999999999999999999999]999999999999999\x90";
|
||||
std::string regex_string(strdata, strdata + sizeof(strdata) - 1);
|
||||
BOOST_TEST_THROWS((boost::regex(regex_string)), boost::regex_error);
|
||||
}
|
||||
{
|
||||
char const strdata[] = "\\k-00000000000000000000000000000000000000000000000000000000009223372036854775807\xff\xff\xff\xff\xff\xff\xff\xef""99999999999999999999999999999999999]999999999999999\x90";
|
||||
std::string regex_string(strdata, strdata + sizeof(strdata) - 1);
|
||||
BOOST_TEST_THROWS((boost::regex(regex_string)), boost::regex_error);
|
||||
}
|
||||
{
|
||||
char const strdata[] = "\\k00000000000000000000000000000000000000000000000000000000009223372036854775807\xff\xff\xff\xff\xff\xff\xff\xef""99999999999999999999999999999999999]999999999999999\x90";
|
||||
std::string regex_string(strdata, strdata + sizeof(strdata) - 1);
|
||||
BOOST_TEST_THROWS((boost::regex(regex_string)), boost::regex_error);
|
||||
}
|
||||
{
|
||||
char const strdata[] = "a(b*)c\\k{--1}d";
|
||||
std::string regex_string(strdata, strdata + sizeof(strdata) - 1);
|
||||
BOOST_TEST_THROWS((boost::regex(regex_string)), boost::regex_error);
|
||||
}
|
||||
{
|
||||
char const strdata[] = "a(b*)c\\k-{-1}d";
|
||||
std::string regex_string(strdata, strdata + sizeof(strdata) - 1);
|
||||
BOOST_TEST_THROWS((boost::regex(regex_string)), boost::regex_error);
|
||||
}
|
||||
{
|
||||
char const strdata[] = "\\k{--00000000000000000000000000000000000000000000000000000000009223372036854775807}\xff\xff\xff\xff\xff\xff\xff\xef""99999999999999999999999999999999999]999999999999999\x90";
|
||||
std::string regex_string(strdata, strdata + sizeof(strdata) - 1);
|
||||
BOOST_TEST_THROWS((boost::regex(regex_string)), boost::regex_error);
|
||||
}
|
||||
{
|
||||
char const strdata[] = "\\k{-00000000000000000000000000000000000000000000000000000000009223372036854775807}\xff\xff\xff\xff\xff\xff\xff\xef""99999999999999999999999999999999999]999999999999999\x90";
|
||||
std::string regex_string(strdata, strdata + sizeof(strdata) - 1);
|
||||
BOOST_TEST_THROWS((boost::regex(regex_string)), boost::regex_error);
|
||||
}
|
||||
{
|
||||
char const strdata[] = "\\k{00000000000000000000000000000000000000000000000000000000009223372036854775807}\xff\xff\xff\xff\xff\xff\xff\xef""99999999999999999999999999999999999]999999999999999\x90";
|
||||
std::string regex_string(strdata, strdata + sizeof(strdata) - 1);
|
||||
BOOST_TEST_THROWS((boost::regex(regex_string)), boost::regex_error);
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
Reference in New Issue
Block a user