aboutsummaryrefslogtreecommitdiffstats
path: root/main/pcre/CVE-2014-8964.patch
blob: 1fb303624d67494d47cc15401384d2ae55da7149 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
From 48d2472840efc4dc54dfc698d64aa086332a9033 Mon Sep 17 00:00:00 2001
From: ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>
Date: Wed, 19 Nov 2014 20:57:13 +0000
Subject: [PATCH] Fix zero-repeat assertion condition bug.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1513 2f5784b3-3f2a-0410-8824-cb99058d5e15
Signed-off-by: Petr Písař <ppisar@redhat.com>

Petr Pisar: Ported to 8.36.

diff --git a/pcre_exec.c b/pcre_exec.c
index fdf7067..bb5620d 100644
--- a/pcre_exec.c
+++ b/pcre_exec.c
@@ -1404,8 +1404,11 @@ for (;;)
         condition = TRUE;
 
         /* Advance ecode past the assertion to the start of the first branch,
-        but adjust it so that the general choosing code below works. */
-
+        but adjust it so that the general choosing code below works. If the 
+        assertion has a quantifier that allows zero repeats we must skip over 
+        the BRAZERO. This is a lunatic thing to do, but somebody did! */
+        
+        if (*ecode == OP_BRAZERO) ecode++; 
         ecode += GET(ecode, 1);
         while (*ecode == OP_ALT) ecode += GET(ecode, 1);
         ecode += 1 + LINK_SIZE - PRIV(OP_lengths)[condcode];
diff --git a/testdata/testinput2 b/testdata/testinput2
index c6816bf..015422e 100644
--- a/testdata/testinput2
+++ b/testdata/testinput2
@@ -4078,4 +4078,10 @@ backtracking verbs. --/
 
 /\x{whatever}/
 
+"((?=(?(?=(?(?=(?(?=())))*)))))"
+    a
+
+"(?(?=)?==)(((((((((?=)))))))))"
+    a
+
 /-- End of testinput2 --/
diff --git a/testdata/testoutput2 b/testdata/testoutput2
index 1e87026..9a1b14e 100644
--- a/testdata/testoutput2
+++ b/testdata/testoutput2
@@ -14206,4 +14206,14 @@ Failed: digits missing in \x{} or \o{} at offset 3
 /\x{whatever}/
 Failed: non-hex character in \x{} (closing brace missing?) at offset 3
 
+"((?=(?(?=(?(?=(?(?=())))*)))))"
+    a
+ 0: 
+ 1: 
+ 2: 
+
+"(?(?=)?==)(((((((((?=)))))))))"
+    a
+No match
+
 /-- End of testinput2 --/
-- 
1.9.3