| @@ -1,50 +1,58 @@ | | | @@ -1,50 +1,58 @@ |
1 | $NetBSD: patch-r42674,v 1.1 2008/04/28 21:35:25 jmmv Exp $
| | 1 | $NetBSD: patch-r42674,v 1.2 2008/04/30 07:13:26 jmmv Exp $ |
2 |
| | 2 | |
3 | Fix for CVE-2008-0171. Patch from Boost's svn repository, r42674.
| | 3 | Fix for CVE-2008-0171. Patch from Boost's svn repository, r42674. |
4 |
| | 4 | |
5 | --- boost/regex/v4/basic_regex_parser.hpp (revision 38864)
| | 5 | --- boost/regex/v4/basic_regex_parser.hpp.orig 2008-04-30 09:00:21.000000000 +0200 |
6 | +++ boost/regex/v4/basic_regex_parser.hpp (revision 42674)
| | 6 | +++ boost/regex/v4/basic_regex_parser.hpp 2008-04-30 09:01:13.000000000 +0200 |
7 | @@ -785,4 +785,5 @@
| | 7 | @@ -784,6 +784,7 @@ bool basic_regex_parser<charT, traits>:: |
8 | case syntax_element_jump:
| | 8 | // do nothing... |
9 | case syntax_element_startmark:
| | 9 | break; |
10 | + case syntax_element_backstep:
| | 10 | } |
11 | // can't legally repeat any of the above:
| | 11 | + case syntax_element_backstep:
|
12 | fail(regex_constants::error_badrepeat, m_position - m_base);
| | 12 | insert_point = this->getoffset(this->m_last_state); |
13 | @@ -1870,4 +1871,5 @@
| | 13 | } |
14 | {
| | 14 | // |
15 | re_syntax_base* b = this->getaddress(expected_alt_point);
| | 15 | @@ -1869,6 +1870,7 @@ bool basic_regex_parser<charT, traits>:: |
16 | + // Make sure we have exactly one alternative following this state:
| | 16 | } |
17 | if(b->type != syntax_element_alt)
| | 17 | else if(this->getaddress(static_cast<re_alt*>(b)->alt.i, b)->type == syntax_element_alt) |
18 | {
| | 18 | { |
19 | @@ -1878,4 +1880,13 @@
| | 19 | + // Make sure we have exactly one alternative following this state:
|
20 | {
| | 20 | fail(regex_constants::error_bad_pattern, m_position - m_base); |
21 | fail(regex_constants::error_bad_pattern, m_position - m_base);
| | 21 | return false; |
22 | + return false;
| | 22 | } |
23 | + }
| | 23 | @@ -1877,6 +1879,15 @@ bool basic_regex_parser<charT, traits>:: |
24 | + // check for invalid repetition of next state:
| | 24 | // append closing parenthesis state: |
25 | + b = this->getaddress(expected_alt_point);
| | 25 | // |
26 | + b = this->getaddress(static_cast<re_alt*>(b)->next.i, b);
| | 26 | pb = static_cast<re_brace*>(this->append_state(syntax_element_endmark, sizeof(re_brace))); |
27 | + if((b->type != syntax_element_assert_backref)
| | 27 | + return false;
|
28 | + && (b->type != syntax_element_startmark))
| | 28 | + }
|
29 | + {
| | 29 | + // check for invalid repetition of next state:
|
30 | + fail(regex_constants::error_badrepeat, m_position - m_base);
| | 30 | + b = this->getaddress(expected_alt_point);
|
31 | return false;
| | 31 | + b = this->getaddress(static_cast<re_alt*>(b)->next.i, b);
|
32 | }
| | 32 | + if((b->type != syntax_element_assert_backref)
|
33 | --- libs/regex/test/regress/test_perl_ex.cpp (revision 30980)
| | 33 | + && (b->type != syntax_element_startmark))
|
34 | +++ libs/regex/test/regress/test_perl_ex.cpp (revision 42674)
| | 34 | + {
|
35 | @@ -122,4 +122,15 @@
| | 35 | + fail(regex_constants::error_badrepeat, m_position - m_base);
|
36 | TEST_INVALID_REGEX("(?:(a)|b)(?(?<", perl);
| | 36 | pb->index = markid; |
37 | TEST_INVALID_REGEX("(?:(a)|b)(?(?<a", perl);
| | 37 | this->m_paren_start = last_paren_start; |
38 | +
| | 38 | // |
39 | + TEST_INVALID_REGEX("(?(?!#?)+)", perl);
| | 39 | --- libs/regex/test/regress/test_perl_ex.cpp.orig 2008-04-30 09:00:21.000000000 +0200 |
40 | + TEST_INVALID_REGEX("(?(?=:-){0})", perl);
| | 40 | +++ libs/regex/test/regress/test_perl_ex.cpp 2008-04-30 09:01:13.000000000 +0200 |
41 | + TEST_INVALID_REGEX("(?(123){1})", perl);
| | 41 | @@ -121,6 +121,17 @@ void test_conditionals() |
42 | + TEST_INVALID_REGEX("(?(?<=A)*)", perl);
| | 42 | TEST_INVALID_REGEX("(?:(a)|b)(?(?:", perl); |
43 | + TEST_INVALID_REGEX("(?(?<=A)+)", perl);
| | 43 | TEST_INVALID_REGEX("(?:(a)|b)(?(?<", perl); |
44 | +
| | 44 | TEST_INVALID_REGEX("(?:(a)|b)(?(?<a", perl); |
45 | + TEST_INVALID_REGEX("(?<!*|^)", perl);
| | 45 | +
|
46 | + TEST_INVALID_REGEX("(?<!*|A)", perl);
| | 46 | + TEST_INVALID_REGEX("(?(?!#?)+)", perl);
|
47 | + TEST_INVALID_REGEX("(?<=?|A)", perl);
| | 47 | + TEST_INVALID_REGEX("(?(?=:-){0})", perl);
|
48 | + TEST_INVALID_REGEX("(?<=*|\B)", perl);
| | 48 | + TEST_INVALID_REGEX("(?(123){1})", perl);
|
49 | }
| | 49 | + TEST_INVALID_REGEX("(?(?<=A)*)", perl);
|
50 |
| | 50 | + TEST_INVALID_REGEX("(?(?<=A)+)", perl);
|
| | | 51 | +
|
| | | 52 | + TEST_INVALID_REGEX("(?<!*|^)", perl);
|
| | | 53 | + TEST_INVALID_REGEX("(?<!*|A)", perl);
|
| | | 54 | + TEST_INVALID_REGEX("(?<=?|A)", perl);
|
| | | 55 | + TEST_INVALID_REGEX("(?<=*|\B)", perl);
|
| | | 56 | } |
| | | 57 | |
| | | 58 | void test_options() |