chiark / gitweb /
a8c15f3655f01508837f93437feae8ae48575625
[pcre3.git] / debian / patches / Fix-compiler-crash-misbehaviour-for-zero-repeated-gr.patch
1 Description: PCRE Library Stack Overflow Vulnerability
2  Fix compiler crash/misbehaviour for zero-repeated groups that
3  include a recursive back reference.
4 Origin: backport, http://vcs.pcre.org/pcre?view=revision&revision=1495
5 Bug: https://bugs.exim.org/show_bug.cgi?id=1503
6 Forwarded: not-needed
7 Last-Update: 2015-09-10
8 Applied-Upstream: 8.36
9 ---
10 --- a/pcre_compile.c
11 +++ b/pcre_compile.c
12 @@ -8241,12 +8241,16 @@ for (;;)
13  
14      /* If it was a capturing subpattern, check to see if it contained any
15      recursive back references. If so, we must wrap it in atomic brackets.
16 -    In any event, remove the block from the chain. */
17 +    Because we are moving code along, we must ensure that any pending recursive
18 +    references are updated. In any event, remove the block from the chain. */
19  
20      if (capnumber > 0)
21        {
22        if (cd->open_caps->flag)
23          {
24 +        *code = OP_END;
25 +        adjust_recurse(start_bracket, 1 + LINK_SIZE,
26 +          (options & PCRE_UTF8) != 0, cd, cd->hwm);
27          memmove(start_bracket + 1 + LINK_SIZE, start_bracket,
28            IN_UCHARS(code - start_bracket));
29          *start_bracket = OP_ONCE;
30 --- a/testdata/testinput11
31 +++ b/testdata/testinput11
32 @@ -132,4 +132,6 @@ is required for these tests. --/
33  
34  /abc(d|e)(*THEN)x(123(*THEN)4|567(b|q)(*THEN)xx)/B
35  
36 +/(((a\2)|(a*)\g<-1>))*a?/B
37 +
38  /-- End of testinput11 --/
39 --- a/testdata/testinput2
40 +++ b/testdata/testinput2
41 @@ -4035,6 +4035,8 @@ backtracking verbs. --/
42  
43  /(?(R&6yh)abc)/
44  
45 +/(((a\2)|(a*)\g<-1>))*a?/BZ
46 +
47  /-- Test the ugly "start or end of word" compatibility syntax --/
48  
49  /[[:<:]]red[[:>:]]/BZ
50 --- a/testdata/testoutput11-16
51 +++ b/testdata/testoutput11-16
52 @@ -709,4 +709,28 @@ Memory allocation (code space): 14
53   62     End
54  ------------------------------------------------------------------
55  
56 +/(((a\2)|(a*)\g<-1>))*a?/B
57 +------------------------------------------------------------------
58 +  0  39 Bra
59 +  2     Brazero
60 +  3  32 SCBra 1
61 +  6  27 Once
62 +  8  12 CBra 2
63 + 11   7 CBra 3
64 + 14     a
65 + 16     \2
66 + 18   7 Ket
67 + 20  11 Alt
68 + 22   5 CBra 4
69 + 25     a*
70 + 27   5 Ket
71 + 29  22 Recurse
72 + 31  23 Ket
73 + 33  27 Ket
74 + 35  32 KetRmax
75 + 37     a?+
76 + 39  39 Ket
77 + 41     End
78 +------------------------------------------------------------------
79 +
80  /-- End of testinput11 --/
81 --- a/testdata/testoutput11-32
82 +++ b/testdata/testoutput11-32
83 @@ -709,4 +709,28 @@ Memory allocation (code space): 28
84   62     End
85  ------------------------------------------------------------------
86  
87 +/(((a\2)|(a*)\g<-1>))*a?/B
88 +------------------------------------------------------------------
89 +  0  39 Bra
90 +  2     Brazero
91 +  3  32 SCBra 1
92 +  6  27 Once
93 +  8  12 CBra 2
94 + 11   7 CBra 3
95 + 14     a
96 + 16     \2
97 + 18   7 Ket
98 + 20  11 Alt
99 + 22   5 CBra 4
100 + 25     a*
101 + 27   5 Ket
102 + 29  22 Recurse
103 + 31  23 Ket
104 + 33  27 Ket
105 + 35  32 KetRmax
106 + 37     a?+
107 + 39  39 Ket
108 + 41     End
109 +------------------------------------------------------------------
110 +
111  /-- End of testinput11 --/
112 --- a/testdata/testoutput11-8
113 +++ b/testdata/testoutput11-8
114 @@ -709,4 +709,28 @@ Memory allocation (code space): 10
115   76     End
116  ------------------------------------------------------------------
117  
118 +/(((a\2)|(a*)\g<-1>))*a?/B
119 +------------------------------------------------------------------
120 +  0  57 Bra
121 +  3     Brazero
122 +  4  48 SCBra 1
123 +  9  40 Once
124 + 12  18 CBra 2
125 + 17  10 CBra 3
126 + 22     a
127 + 24     \2
128 + 27  10 Ket
129 + 30  16 Alt
130 + 33   7 CBra 4
131 + 38     a*
132 + 40   7 Ket
133 + 43  33 Recurse
134 + 46  34 Ket
135 + 49  40 Ket
136 + 52  48 KetRmax
137 + 55     a?+
138 + 57  57 Ket
139 + 60     End
140 +------------------------------------------------------------------
141 +
142  /-- End of testinput11 --/
143 --- a/testdata/testoutput2
144 +++ b/testdata/testoutput2
145 @@ -14093,6 +14093,30 @@ Failed: malformed number or name after (
146  /(?(R&6yh)abc)/
147  Failed: group name must start with a non-digit at offset 5
148  
149 +/(((a\2)|(a*)\g<-1>))*a?/BZ
150 +------------------------------------------------------------------
151 +        Bra
152 +        Brazero
153 +        SCBra 1
154 +        Once
155 +        CBra 2
156 +        CBra 3
157 +        a
158 +        \2
159 +        Ket
160 +        Alt
161 +        CBra 4
162 +        a*
163 +        Ket
164 +        Recurse
165 +        Ket
166 +        Ket
167 +        KetRmax
168 +        a?+
169 +        Ket
170 +        End
171 +------------------------------------------------------------------
172 +
173  /-- Test the ugly "start or end of word" compatibility syntax --/
174  
175  /[[:<:]]red[[:>:]]/BZ