summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/perl/perl/CVE-2018-18314.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/perl/perl/CVE-2018-18314.patch')
-rw-r--r--meta/recipes-devtools/perl/perl/CVE-2018-18314.patch271
1 files changed, 271 insertions, 0 deletions
diff --git a/meta/recipes-devtools/perl/perl/CVE-2018-18314.patch b/meta/recipes-devtools/perl/perl/CVE-2018-18314.patch
new file mode 100644
index 0000000000..e84e7bc4e4
--- /dev/null
+++ b/meta/recipes-devtools/perl/perl/CVE-2018-18314.patch
@@ -0,0 +1,271 @@
1From 6a2d07f43ae7cfcb2eb30cf39751f2f7fed7ecc1 Mon Sep 17 00:00:00 2001
2From: Yves Orton <demerphq@gmail.com>
3Date: Mon, 26 Jun 2017 13:19:55 +0200
4Subject: [PATCH 3/3] fix #131649 - extended charclass can trigger assert
5
6The extended charclass parser makes some assumptions during the
7first pass which are only true on well structured input, and it
8does not properly catch various errors. later on the code assumes
9that things the first pass will let through are valid, when in
10fact they should trigger errors.
11
12(cherry picked from commit 19a498a461d7c81ae3507c450953d1148efecf4f)
13
14CVE: CVE-2018-18314
15Upstream-Status: Backport
16[https://perl5.git.perl.org/perl.git/commit/dabe076af345ab4512ea80245b4e4cd7ec0996cd]
17
18Signed-off-by: Dan Tran <dantran@microsoft.com>
19---
20 pod/perldiag.pod | 27 ++++++++++++++++++++++++++-
21 pod/perlrecharclass.pod | 4 ++--
22 regcomp.c | 23 +++++++++++++----------
23 t/lib/warnings/regcomp | 6 +++---
24 t/re/reg_mesg.t | 29 ++++++++++++++++-------------
25 t/re/regex_sets.t | 6 +++---
26 6 files changed, 63 insertions(+), 32 deletions(-)
27
28diff --git a/pod/perldiag.pod b/pod/perldiag.pod
29index 737d3633f6..644b814008 100644
30--- a/pod/perldiag.pod
31+++ b/pod/perldiag.pod
32@@ -5777,7 +5777,7 @@ yourself.
33 a perl4 interpreter, especially if the next 2 tokens are "use strict"
34 or "my $var" or "our $var".
35
36-=item Syntax error in (?[...]) in regex m/%s/
37+=item Syntax error in (?[...]) in regex; marked by <-- HERE in m/%s/
38
39 (F) Perl could not figure out what you meant inside this construct; this
40 notifies you that it is giving up trying.
41@@ -6153,6 +6153,31 @@ for example,
42 (F) The unexec() routine failed for some reason. See your local FSF
43 representative, who probably put it there in the first place.
44
45+=item Unexpected ']' with no following ')' in (?[... in regex; marked by <-- HERE in m/%s/
46+
47+(F) While parsing an extended character class a ']' character was encountered
48+at a point in the definition where the only legal use of ']' is to close the
49+character class definition as part of a '])', you may have forgotten the close
50+paren, or otherwise confused the parser.
51+
52+=item Expecting close paren for nested extended charclass in regex; marked by <-- HERE in m/%s/
53+
54+(F) While parsing a nested extended character class like:
55+
56+ (?[ ... (?flags:(?[ ... ])) ... ])
57+ ^
58+
59+we expected to see a close paren ')' (marked by ^) but did not.
60+
61+=item Expecting close paren for wrapper for nested extended charclass in regex; marked by <-- HERE in m/%s/
62+
63+(F) While parsing a nested extended character class like:
64+
65+ (?[ ... (?flags:(?[ ... ])) ... ])
66+ ^
67+
68+we expected to see a close paren ')' (marked by ^) but did not.
69+
70 =item Unexpected binary operator '%c' with no preceding operand in regex;
71 marked by S<<-- HERE> in m/%s/
72
73diff --git a/pod/perlrecharclass.pod b/pod/perlrecharclass.pod
74index 89f4a7ef3f..a557cc0384 100644
75--- a/pod/perlrecharclass.pod
76+++ b/pod/perlrecharclass.pod
77@@ -1101,8 +1101,8 @@ hence both of the following work:
78 Any contained POSIX character classes, including things like C<\w> and C<\D>
79 respect the C<E<sol>a> (and C<E<sol>aa>) modifiers.
80
81-C<< (?[ ]) >> is a regex-compile-time construct. Any attempt to use
82-something which isn't knowable at the time the containing regular
83+Note that C<< (?[ ]) >> is a regex-compile-time construct. Any attempt
84+to use something which isn't knowable at the time the containing regular
85 expression is compiled is a fatal error. In practice, this means
86 just three limitations:
87
88diff --git a/regcomp.c b/regcomp.c
89index 2688979882..cb8409ed27 100644
90--- a/regcomp.c
91+++ b/regcomp.c
92@@ -14609,8 +14609,9 @@ S_handle_regex_sets(pTHX_ RExC_state_t *pRExC_state, SV** return_invlist,
93 TRUE /* Force /x */ );
94
95 switch (*RExC_parse) {
96- case '?':
97- if (RExC_parse[1] == '[') depth++, RExC_parse++;
98+ case '(':
99+ if (RExC_parse[1] == '?' && RExC_parse[2] == '[')
100+ depth++, RExC_parse+=2;
101 /* FALLTHROUGH */
102 default:
103 break;
104@@ -14667,9 +14668,9 @@ S_handle_regex_sets(pTHX_ RExC_state_t *pRExC_state, SV** return_invlist,
105 }
106
107 case ']':
108- if (depth--) break;
109- RExC_parse++;
110- if (*RExC_parse == ')') {
111+ if (RExC_parse[1] == ')') {
112+ RExC_parse++;
113+ if (depth--) break;
114 node = reganode(pRExC_state, ANYOF, 0);
115 RExC_size += ANYOF_SKIP;
116 nextchar(pRExC_state);
117@@ -14681,20 +14682,20 @@ S_handle_regex_sets(pTHX_ RExC_state_t *pRExC_state, SV** return_invlist,
118
119 return node;
120 }
121- goto no_close;
122+ RExC_parse++;
123+ vFAIL("Unexpected ']' with no following ')' in (?[...");
124 }
125
126 RExC_parse += UTF ? UTF8SKIP(RExC_parse) : 1;
127 }
128
129- no_close:
130 /* We output the messages even if warnings are off, because we'll fail
131 * the very next thing, and these give a likely diagnosis for that */
132 if (posix_warnings && av_tindex_nomg(posix_warnings) >= 0) {
133 output_or_return_posix_warnings(pRExC_state, posix_warnings, NULL);
134 }
135
136- FAIL("Syntax error in (?[...])");
137+ vFAIL("Syntax error in (?[...])");
138 }
139
140 /* Pass 2 only after this. */
141@@ -14868,12 +14869,14 @@ redo_curchar:
142 * inversion list, and RExC_parse points to the trailing
143 * ']'; the next character should be the ')' */
144 RExC_parse++;
145- assert(UCHARAT(RExC_parse) == ')');
146+ if (UCHARAT(RExC_parse) != ')')
147+ vFAIL("Expecting close paren for nested extended charclass");
148
149 /* Then the ')' matching the original '(' handled by this
150 * case: statement */
151 RExC_parse++;
152- assert(UCHARAT(RExC_parse) == ')');
153+ if (UCHARAT(RExC_parse) != ')')
154+ vFAIL("Expecting close paren for wrapper for nested extended charclass");
155
156 RExC_flags = save_flags;
157 goto handle_operand;
158diff --git a/t/lib/warnings/regcomp b/t/lib/warnings/regcomp
159index 08cb27b00f..367276d0fc 100644
160--- a/t/lib/warnings/regcomp
161+++ b/t/lib/warnings/regcomp
162@@ -59,21 +59,21 @@ Unmatched [ in regex; marked by <-- HERE in m/abc[ <-- HERE fi[.00./ at - line
163 qr/(?[[[:word]]])/;
164 EXPECT
165 Assuming NOT a POSIX class since there is no terminating ':' in regex; marked by <-- HERE in m/(?[[[:word <-- HERE ]]])/ at - line 2.
166-syntax error in (?[...]) in regex m/(?[[[:word]]])/ at - line 2.
167+Unexpected ']' with no following ')' in (?[... in regex; marked by <-- HERE in m/(?[[[:word]] <-- HERE ])/ at - line 2.
168 ########
169 # NAME qr/(?[ [[:digit: ])/
170 # OPTION fatal
171 qr/(?[[[:digit: ])/;
172 EXPECT
173 Assuming NOT a POSIX class since no blanks are allowed in one in regex; marked by <-- HERE in m/(?[[[:digit: ] <-- HERE )/ at - line 2.
174-syntax error in (?[...]) in regex m/(?[[[:digit: ])/ at - line 2.
175+syntax error in (?[...]) in regex; marked by <-- HERE in m/(?[[[:digit: ]) <-- HERE / at - line 2.
176 ########
177 # NAME qr/(?[ [:digit: ])/
178 # OPTION fatal
179 qr/(?[[:digit: ])/
180 EXPECT
181 Assuming NOT a POSIX class since no blanks are allowed in one in regex; marked by <-- HERE in m/(?[[:digit: ] <-- HERE )/ at - line 2.
182-syntax error in (?[...]) in regex m/(?[[:digit: ])/ at - line 2.
183+syntax error in (?[...]) in regex; marked by <-- HERE in m/(?[[:digit: ]) <-- HERE / at - line 2.
184 ########
185 # NAME [perl #126141]
186 # OPTION fatal
187diff --git a/t/re/reg_mesg.t b/t/re/reg_mesg.t
188index 658397ac27..08a3688e1d 100644
189--- a/t/re/reg_mesg.t
190+++ b/t/re/reg_mesg.t
191@@ -202,8 +202,9 @@ my @death =
192 '/\b{gc}/' => "'gc' is an unknown bound type {#} m/\\b{gc{#}}/",
193 '/\B{gc}/' => "'gc' is an unknown bound type {#} m/\\B{gc{#}}/",
194
195- '/(?[[[::]]])/' => "Syntax error in (?[...]) in regex m/(?[[[::]]])/",
196- '/(?[[[:w:]]])/' => "Syntax error in (?[...]) in regex m/(?[[[:w:]]])/",
197+
198+ '/(?[[[::]]])/' => "Unexpected ']' with no following ')' in (?[... {#} m/(?[[[::]]{#}])/",
199+ '/(?[[[:w:]]])/' => "Unexpected ']' with no following ')' in (?[... {#} m/(?[[[:w:]]{#}])/",
200 '/(?[[:w:]])/' => "",
201 '/[][[:alpha:]]' => "", # [perl #127581]
202 '/([.].*)[.]/' => "", # [perl #127582]
203@@ -227,11 +228,12 @@ my @death =
204 '/(?[ \p{foo} ])/' => 'Can\'t find Unicode property definition "foo" {#} m/(?[ \p{foo}{#} ])/',
205 '/(?[ \p{ foo = bar } ])/' => 'Can\'t find Unicode property definition "foo = bar" {#} m/(?[ \p{ foo = bar }{#} ])/',
206 '/(?[ \8 ])/' => 'Unrecognized escape \8 in character class {#} m/(?[ \8{#} ])/',
207- '/(?[ \t ]/' => 'Syntax error in (?[...]) in regex m/(?[ \t ]/',
208- '/(?[ [ \t ]/' => 'Syntax error in (?[...]) in regex m/(?[ [ \t ]/',
209- '/(?[ \t ] ]/' => 'Syntax error in (?[...]) in regex m/(?[ \t ] ]/',
210- '/(?[ [ ] ]/' => 'Syntax error in (?[...]) in regex m/(?[ [ ] ]/',
211- '/(?[ \t + \e # This was supposed to be a comment ])/' => 'Syntax error in (?[...]) in regex m/(?[ \t + \e # This was supposed to be a comment ])/',
212+ '/(?[ \t ]/' => "Unexpected ']' with no following ')' in (?[... {#} m/(?[ \\t ]{#}/",
213+ '/(?[ [ \t ]/' => "Syntax error in (?[...]) {#} m/(?[ [ \\t ]{#}/",
214+ '/(?[ \t ] ]/' => "Unexpected ']' with no following ')' in (?[... {#} m/(?[ \\t ]{#} ]/",
215+ '/(?[ [ ] ]/' => "Syntax error in (?[...]) {#} m/(?[ [ ] ]{#}/",
216+ '/(?[ \t + \e # This was supposed to be a comment ])/' =>
217+ "Syntax error in (?[...]) {#} m/(?[ \\t + \\e # This was supposed to be a comment ]){#}/",
218 '/(?[ ])/' => 'Incomplete expression within \'(?[ ])\' {#} m/(?[ {#}])/',
219 'm/(?[[a-\d]])/' => 'False [] range "a-\d" {#} m/(?[[a-\d{#}]])/',
220 'm/(?[[\w-x]])/' => 'False [] range "\w-" {#} m/(?[[\w-{#}x]])/',
221@@ -410,10 +412,10 @@ my @death_utf8 = mark_as_utf8(
222
223 '/ネ\p{}ネ/' => 'Empty \p{} {#} m/ネ\p{{#}}ネ/',
224
225- '/ネ(?[[[:ネ]]])ネ/' => "Syntax error in (?[...]) in regex m/ネ(?[[[:ネ]]])ネ/",
226- '/ネ(?[[[:ネ: ])ネ/' => "Syntax error in (?[...]) in regex m/ネ(?[[[:ネ: ])ネ/",
227- '/ネ(?[[[::]]])ネ/' => "Syntax error in (?[...]) in regex m/ネ(?[[[::]]])ネ/",
228- '/ネ(?[[[:ネ:]]])ネ/' => "Syntax error in (?[...]) in regex m/ネ(?[[[:ネ:]]])ネ/",
229+ '/ネ(?[[[:ネ]]])ネ/' => "Unexpected ']' with no following ')' in (?[... {#} m/ネ(?[[[:ネ]]{#}])ネ/",
230+ '/ネ(?[[[:ネ: ])ネ/' => "Syntax error in (?[...]) {#} m/ネ(?[[[:ネ: ])ネ{#}/",
231+ '/ネ(?[[[::]]])ネ/' => "Unexpected ']' with no following ')' in (?[... {#} m/ネ(?[[[::]]{#}])ネ/",
232+ '/ネ(?[[[:ネ:]]])ネ/' => "Unexpected ']' with no following ')' in (?[... {#} m/ネ(?[[[:ネ:]]{#}])ネ/",
233 '/ネ(?[[:ネ:]])ネ/' => "",
234 '/ネ(?[ネ])ネ/' => 'Unexpected character {#} m/ネ(?[ネ{#}])ネ/',
235 '/ネ(?[ + [ネ] ])/' => 'Unexpected binary operator \'+\' with no preceding operand {#} m/ネ(?[ +{#} [ネ] ])/',
236@@ -426,8 +428,9 @@ my @death_utf8 = mark_as_utf8(
237 '/(?[ \x{ネ} ])ネ/' => 'Non-hex character {#} m/(?[ \x{ネ{#}} ])ネ/',
238 '/(?[ \p{ネ} ])/' => 'Can\'t find Unicode property definition "ネ" {#} m/(?[ \p{ネ}{#} ])/',
239 '/(?[ \p{ ネ = bar } ])/' => 'Can\'t find Unicode property definition "ネ = bar" {#} m/(?[ \p{ ネ = bar }{#} ])/',
240- '/ネ(?[ \t ]/' => 'Syntax error in (?[...]) in regex m/ネ(?[ \t ]/',
241- '/(?[ \t + \e # ネ This was supposed to be a comment ])/' => 'Syntax error in (?[...]) in regex m/(?[ \t + \e # ネ This was supposed to be a comment ])/',
242+ '/ネ(?[ \t ]/' => "Unexpected ']' with no following ')' in (?[... {#} m/ネ(?[ \\t ]{#}/",
243+ '/(?[ \t + \e # ネ This was supposed to be a comment ])/' =>
244+ "Syntax error in (?[...]) {#} m/(?[ \\t + \\e # ネ This was supposed to be a comment ]){#}/",
245 'm/(*ネ)ネ/' => q<Unknown verb pattern 'ネ' {#} m/(*ネ){#}ネ/>,
246 '/\cネ/' => "Character following \"\\c\" must be printable ASCII",
247 '/\b{ネ}/' => "'ネ' is an unknown bound type {#} m/\\b{ネ{#}}/",
248diff --git a/t/re/regex_sets.t b/t/re/regex_sets.t
249index 92875677be..60a126ba3c 100644
250--- a/t/re/regex_sets.t
251+++ b/t/re/regex_sets.t
252@@ -157,13 +157,13 @@ for my $char ("٠", "٥", "٩") {
253 eval { $_ = '/(?[(\c]) /'; qr/$_/ };
254 like($@, qr/^Syntax error/, '/(?[(\c]) / should not panic');
255 eval { $_ = '(?[\c#]' . "\n])"; qr/$_/ };
256- like($@, qr/^Syntax error/, '/(?[(\c]) / should not panic');
257+ like($@, qr/^Unexpected/, '/(?[(\c]) / should not panic');
258 eval { $_ = '(?[(\c])'; qr/$_/ };
259 like($@, qr/^Syntax error/, '/(?[(\c])/ should be a syntax error');
260 eval { $_ = '(?[(\c]) ]\b'; qr/$_/ };
261- like($@, qr/^Syntax error/, '/(?[(\c]) ]\b/ should be a syntax error');
262+ like($@, qr/^Unexpected/, '/(?[(\c]) ]\b/ should be a syntax error');
263 eval { $_ = '(?[\c[]](])'; qr/$_/ };
264- like($@, qr/^Syntax error/, '/(?[\c[]](])/ should be a syntax error');
265+ like($@, qr/^Unexpected/, '/(?[\c[]](])/ should be a syntax error');
266 like("\c#", qr/(?[\c#])/, '\c# should match itself');
267 like("\c[", qr/(?[\c[])/, '\c[ should match itself');
268 like("\c\ ", qr/(?[\c\])/, '\c\ should match itself');
269--
2702.22.0.vfs.1.1.57.gbaf16c8
271