summaryrefslogtreecommitdiffstats
path: root/meta/recipes-support/libpcre/libpcre2/CVE-2022-41409.patch
blob: 882277ae73b4147ca9ba71b0972a9120dfc5b060 (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
69
70
71
72
73
74
From 94e1c001761373b7d9450768aa15d04c25547a35 Mon Sep 17 00:00:00 2001
From: Philip Hazel <Philip.Hazel@gmail.com>
Date: Tue, 16 Aug 2022 17:00:45 +0100
Subject: [PATCH] Diagnose negative repeat value in pcre2test subject line

CVE: CVE-2022-41409
Upstream-Status: Backport [https://github.com/PCRE2Project/pcre2/commit/94e1c001761373b7d9450768aa15d04c25547a35]

Signed-off-by: Peter Marko <peter.marko@siemens.com>

---
 ChangeLog            | 3 +++
 src/pcre2test.c      | 4 ++--
 testdata/testinput2  | 3 +++
 testdata/testoutput2 | 4 ++++
 4 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index eab50eb7..276eb57a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,9 @@ fully read in caseless matching.
 24. Fixed an issue affecting recursions in JIT caused by duplicated data
 transfers.
 
+20. A negative repeat value in a pcre2test subject line was not being 
+diagnosed, leading to infinite looping.
+
 
 Version 10.34 21-November-2019
 ------------------------------
diff --git a/src/pcre2test.c b/src/pcre2test.c
index 08f86096..f6f5d66c 100644
--- a/src/pcre2test.c
+++ b/src/pcre2test.c
@@ -6700,9 +6700,9 @@ while ((c = *p++) != 0)
       }
 
     i = (int32_t)li;
-    if (i-- == 0)
+    if (i-- <= 0)
       {
-      fprintf(outfile, "** Zero repeat not allowed\n");
+      fprintf(outfile, "** Zero or negative repeat not allowed\n");
       return PR_OK;
       }
 
diff --git a/testdata/testinput2 b/testdata/testinput2
index 655e519..14e00ed 100644
--- a/testdata/testinput2
+++ b/testdata/testinput2
@@ -5772,4 +5772,7 @@ a)"xI
 /(a)?a/I
     manm
 
+--
+    \[X]{-10}
+
 # End of testinput2
diff --git a/testdata/testoutput2 b/testdata/testoutput2
index c733c12..958f246 100644
--- a/testdata/testoutput2
+++ b/testdata/testoutput2
@@ -17435,6 +17435,10 @@ Subject length lower bound = 1
     manm
  0: a
 
+--
+    \[X]{-10}
+** Zero or negative repeat not allowed
+
 # End of testinput2
 Error -70: PCRE2_ERROR_BADDATA (unknown error number)
 Error -62: bad serialized data