chiark / gitweb /
pcre3 (2:8.38-3.1) unstable; urgency=medium
[pcre3.git] / debian / patches / apply-upstream-revision-1631-closes-8159
1 Description: Apply upstream revision 1631 (Closes: #815921)
2  This is an upstream patch to fix workspace overflow for (*ACCEPT) with
3  deeply nested parentheses
4 Author: Matthew Vernon <matthew@debian.org>
5 X-Dgit-Generated: 2:8.38-2 50aa7778a6bb8b81a9e03e8744f797362183772e
6
7 ---
8
9 --- pcre3-8.38.orig/pcreposix.c
10 +++ pcre3-8.38/pcreposix.c
11 @@ -6,7 +6,7 @@
12  and semantics are as close as possible to those of the Perl 5 language.
13  
14                         Written by Philip Hazel
15 -           Copyright (c) 1997-2014 University of Cambridge
16 +           Copyright (c) 1997-2016 University of Cambridge
17  
18  -----------------------------------------------------------------------------
19  Redistribution and use in source and binary forms, with or without
20 @@ -173,7 +173,8 @@ static const int eint[] = {
21    REG_BADPAT,  /* group name must start with a non-digit */
22    /* 85 */
23    REG_BADPAT,  /* parentheses too deeply nested (stack check) */
24 -  REG_BADPAT   /* missing digits in \x{} or \o{} */
25 +  REG_BADPAT,  /* missing digits in \x{} or \o{} */
26 +  REG_BADPAT   /* pattern too complicated */
27  };
28  
29  /* Table of texts corresponding to POSIX error codes */
30 --- pcre3-8.38.orig/pcre_compile.c
31 +++ pcre3-8.38/pcre_compile.c
32 @@ -6,7 +6,7 @@
33  and semantics are as close as possible to those of the Perl 5 language.
34  
35                         Written by Philip Hazel
36 -           Copyright (c) 1997-2014 University of Cambridge
37 +           Copyright (c) 1997-2016 University of Cambridge
38  
39  -----------------------------------------------------------------------------
40  Redistribution and use in source and binary forms, with or without
41 @@ -560,6 +560,7 @@ static const char error_texts[] =
42    /* 85 */
43    "parentheses are too deeply nested (stack check)\0"
44    "digits missing in \\x{} or \\o{}\0"
45 +  "regular expression is too complicated\0"
46    ;
47  
48  /* Table to identify digits and hex digits. This is used when compiling
49 @@ -4591,7 +4592,8 @@ for (;; ptr++)
50      if (code > cd->start_workspace + cd->workspace_size -
51          WORK_SIZE_SAFETY_MARGIN)                       /* Check for overrun */
52        {
53 -      *errorcodeptr = ERR52;
54 +      *errorcodeptr = (code >= cd->start_workspace + cd->workspace_size)?
55 +        ERR52 : ERR87;
56        goto FAILED;
57        }
58  
59 @@ -6604,8 +6606,21 @@ for (;; ptr++)
60              cd->had_accept = TRUE;
61              for (oc = cd->open_caps; oc != NULL; oc = oc->next)
62                {
63 -              *code++ = OP_CLOSE;
64 -              PUT2INC(code, 0, oc->number);
65 +              if (lengthptr != NULL)
66 +                {
67 +#ifdef COMPILE_PCRE8
68 +                *lengthptr += 1 + IMM2_SIZE;
69 +#elif defined COMPILE_PCRE16
70 +                *lengthptr += 2 + IMM2_SIZE;
71 +#elif defined COMPILE_PCRE32
72 +                *lengthptr += 4 + IMM2_SIZE;
73 +#endif
74 +                }
75 +              else
76 +                {
77 +                *code++ = OP_CLOSE;
78 +                PUT2INC(code, 0, oc->number);
79 +                }
80                }
81              setverb = *code++ =
82                (cd->assert_depth > 0)? OP_ASSERT_ACCEPT : OP_ACCEPT;
83 --- pcre3-8.38.orig/pcre_internal.h
84 +++ pcre3-8.38/pcre_internal.h
85 @@ -7,7 +7,7 @@
86  and semantics are as close as possible to those of the Perl 5 language.
87  
88                         Written by Philip Hazel
89 -           Copyright (c) 1997-2014 University of Cambridge
90 +           Copyright (c) 1997-2016 University of Cambridge
91  
92  -----------------------------------------------------------------------------
93  Redistribution and use in source and binary forms, with or without
94 @@ -2289,7 +2289,7 @@ enum { ERR0,  ERR1,  ERR2,  ERR3,  ERR4,
95         ERR50, ERR51, ERR52, ERR53, ERR54, ERR55, ERR56, ERR57, ERR58, ERR59,
96         ERR60, ERR61, ERR62, ERR63, ERR64, ERR65, ERR66, ERR67, ERR68, ERR69,
97         ERR70, ERR71, ERR72, ERR73, ERR74, ERR75, ERR76, ERR77, ERR78, ERR79,
98 -       ERR80, ERR81, ERR82, ERR83, ERR84, ERR85, ERR86, ERRCOUNT };
99 +       ERR80, ERR81, ERR82, ERR83, ERR84, ERR85, ERR86, ERR87, ERRCOUNT };
100  
101  /* JIT compiling modes. The function list is indexed by them. */
102  
103 --- pcre3-8.38.orig/testdata/testoutput11-8
104 +++ pcre3-8.38/testdata/testoutput11-8
105 @@ -765,4 +765,7 @@ Memory allocation (code space): 10
106   38     End
107  ------------------------------------------------------------------
108  
109 +/([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00](*ACCEPT)/
110 +Failed: missing ) at offset 509
111 +
112  /-- End of testinput11 --/
113 --- pcre3-8.38.orig/testdata/testoutput11-16
114 +++ pcre3-8.38/testdata/testoutput11-16
115 @@ -765,4 +765,7 @@ Memory allocation (code space): 14
116   25     End
117  ------------------------------------------------------------------
118  
119 +/([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00](*ACCEPT)/
120 +Failed: regular expression is too complicated at offset 490
121 +
122  /-- End of testinput11 --/
123 --- pcre3-8.38.orig/testdata/testinput11
124 +++ pcre3-8.38/testdata/testinput11
125 @@ -138,4 +138,6 @@ is required for these tests. --/
126  
127  /.((?2)(?R)\1)()/B
128  
129 +/([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00](*ACCEPT)/
130 +
131  /-- End of testinput11 --/
132 --- pcre3-8.38.orig/testdata/testoutput11-32
133 +++ pcre3-8.38/testdata/testoutput11-32
134 @@ -765,4 +765,7 @@ Memory allocation (code space): 28
135   25     End
136  ------------------------------------------------------------------
137  
138 +/([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00]([00](*ACCEPT)/
139 +Failed: missing ) at offset 509
140 +
141  /-- End of testinput11 --/