diff --git a/backport-Fix-incorrect-class-character-matches-in-JIT.patch b/backport-Fix-incorrect-class-character-matches-in-JIT.patch new file mode 100644 index 0000000000000000000000000000000000000000..aed28f174c8219aa4d97007b7a393904eeb80e6e --- /dev/null +++ b/backport-Fix-incorrect-class-character-matches-in-JIT.patch @@ -0,0 +1,69 @@ +From 542cb11242cfc9be9b6218965751bfbb13a8b6a2 Mon Sep 17 00:00:00 2001 +From: Zoltan Herczeg +Date: Wed, 27 Dec 2023 08:27:17 +0000 +Subject: [PATCH] Fix incorrect class character matches in JIT + +Conflict:don't modify ChangLog; adapt context; don't modify hunk:8282 +and "xdigit" in hunk:421 because 494e76578a9 is not mearged +Reference:https://github.com/PCRE2Project/pcre2/commit/542cb11242cfc9be9b6218965751bfbb13a8b6a2 + +--- + src/pcre2_jit_compile.c | 8 ++++++++ + src/pcre2_jit_test.c | 1 + + 2 files changed, 9 insertions(+) + +diff --git a/src/pcre2_jit_compile.c b/src/pcre2_jit_compile.c +index 34c65c2..4ecd331 100644 +--- a/src/pcre2_jit_compile.c ++++ b/src/pcre2_jit_compile.c +@@ -8010,6 +8010,7 @@ while (*cc != XCL_END) + + jump = CMP(SLJIT_NOT_EQUAL, typereg, 0, SLJIT_IMM, ucp_Cf - ucp_Ll); + ++ c = charoffset; + /* In case of ucp_Cf, we overwrite the result. */ + SET_CHAR_OFFSET(0x2066); + OP2(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x2069 - 0x2066); +@@ -8021,6 +8022,9 @@ while (*cc != XCL_END) + OP2(SLJIT_SUB | SLJIT_SET_Z, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x180e - 0x2066); + OP_FLAGS(SLJIT_OR, TMP2, 0, SLJIT_EQUAL); + ++ /* Restore charoffset. */ ++ SET_CHAR_OFFSET(c); ++ + JUMPHERE(jump); + jump = CMP(SLJIT_ZERO ^ invertcmp, TMP2, 0, SLJIT_IMM, 0); + break; +@@ -8036,6 +8040,7 @@ while (*cc != XCL_END) + + jump = CMP(SLJIT_NOT_EQUAL, typereg, 0, SLJIT_IMM, ucp_Cf - ucp_Ll); + ++ c = charoffset; + /* In case of ucp_Cf, we overwrite the result. */ + SET_CHAR_OFFSET(0x2066); + OP2(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x2069 - 0x2066); +@@ -8044,6 +8049,9 @@ while (*cc != XCL_END) + OP2(SLJIT_SUB | SLJIT_SET_Z, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x061c - 0x2066); + OP_FLAGS(SLJIT_OR, TMP2, 0, SLJIT_EQUAL); + ++ /* Restore charoffset. */ ++ SET_CHAR_OFFSET(c); ++ + JUMPHERE(jump); + jump = CMP(SLJIT_ZERO ^ invertcmp, TMP2, 0, SLJIT_IMM, 0); + break; +diff --git a/src/pcre2_jit_test.c b/src/pcre2_jit_test.c +index 54636e3..9abfd57 100644 +--- a/src/pcre2_jit_test.c ++++ b/src/pcre2_jit_test.c +@@ -415,6 +415,7 @@ static struct regression_test_case regression_test_cases[] = { + { PCRE2_UCP, 0, 0, 0 | F_PROPERTY, "[a-b\\s]{2,5}[^a]", "AB baaa" }, + { MUP, 0, 0, 0 | F_NOMATCH, "[^\\p{Hangul}\\p{Z}]", " " }, + { CMUP, 0, 0, 0, "[^S]\\B", "\xe2\x80\x8a" }, ++ { MUP, 0, 0, 0 | F_NOMATCH, "[^[:print:]\\x{f6f6}]", "\xef\x9b\xb6" }, + + /* Possible empty brackets. */ + { MU, A, 0, 0, "(?:|ab||bc|a)+d", "abcxabcabd" }, +-- +2.23.0 + diff --git a/backport-Sanity-checks-for-ctype-functions-342.patch b/backport-Sanity-checks-for-ctype-functions-342.patch new file mode 100644 index 0000000000000000000000000000000000000000..75e17a85422f10356baea34c90f081323644774f --- /dev/null +++ b/backport-Sanity-checks-for-ctype-functions-342.patch @@ -0,0 +1,91 @@ +From 9783ca9bed0cfb682e7bc76ed605aeb38571930a Mon Sep 17 00:00:00 2001 +From: Addison Crump +Date: Sat, 18 Nov 2023 16:52:00 +0100 +Subject: [PATCH] Sanity checks for ctype functions (#342) + +Conflict:don't modify pcre2_compile.c because 0246c6bf643 is not mearged +Reference:https://github.com/PCRE2Project/pcre2/commit/9783ca9bed0cfb682e7bc76ed605aeb38571930a + +* fixup: sanity checks for ctype functions + +* format + +* more grep fixes + +* don't check if constrained by type +--- + src/pcre2_convert.c | 8 ++++++++ + src/pcre2grep.c | 10 +++++----- + 2 files changed, 13 insertions(+), 5 deletions(-) + +diff --git a/src/pcre2_convert.c b/src/pcre2_convert.c +index 36466e4..fe396ae 100644 +--- a/src/pcre2_convert.c ++++ b/src/pcre2_convert.c +@@ -540,6 +540,14 @@ Returns: !0 => character is found in the class + static BOOL + convert_glob_char_in_class(int class_index, PCRE2_UCHAR c) + { ++#if PCRE2_CODE_UNIT_WIDTH != 8 ++if (c > 0xff) ++ { ++ /* ctype functions are not sane for c > 0xff */ ++ return 0; ++ } ++#endif ++ + switch (class_index) + { + case 1: return isalnum(c); +diff --git a/src/pcre2grep.c b/src/pcre2grep.c +index 776aa28..73cf45a 100644 +--- a/src/pcre2grep.c ++++ b/src/pcre2grep.c +@@ -796,7 +796,7 @@ decode_ANSI_colour(const char *cs) + WORD result = csbi.wAttributes; + while (*cs) + { +- if (isdigit(*cs)) ++ if (isdigit((unsigned char)(*cs))) + { + int code = atoi(cs); + if (code == 1) result |= 0x08; +@@ -810,7 +810,7 @@ while (*cs) + else if (code >= 90 && code <= 97) result = (result & 0xF0) | BGR_RGB(code - 90) | 0x08; + else if (code >= 100 && code <= 107) result = (result & 0x0F) | (BGR_RGB(code - 100) << 4) | 0x80; + +- while (isdigit(*cs)) cs++; ++ while (isdigit((unsigned char)(*cs))) cs++; + } + if (*cs) cs++; + } +@@ -1989,7 +1989,7 @@ switch (*(++string)) + case '{': + brace = TRUE; + string++; +- if (!isdigit(*string)) /* Syntax error: a decimal number required. */ ++ if (!isdigit((unsigned char)(*string))) /* Syntax error: a decimal number required. */ + { + if (!callout) + fprintf(stderr, "pcre2grep: Error in output text at offset %d: %s\n", +@@ -4036,7 +4036,7 @@ for (i = 1; i < argc; i++) + + if (op->type == OP_OP_NUMBER || op->type == OP_OP_NUMBERS) + { +- if (isdigit((unsigned char)s[1])) break; ++ if (isdigit((unsigned char)(s[1]))) break; + } + else /* Check for an option with data */ + { +@@ -4520,7 +4520,7 @@ for (fn = file_lists; fn != NULL; fn = fn->next) + { + int frc; + char *end = buffer + (int)strlen(buffer); +- while (end > buffer && isspace(end[-1])) end--; ++ while (end > buffer && isspace((unsigned char)(end[-1]))) end--; + *end = 0; + if (*buffer != 0) + { +-- +2.23.0 + diff --git a/pcre2.spec b/pcre2.spec index 05caa4b98a6b167af4e80964ef91bf631b7523f8..8fcb4395c17147bb0de42da2967a3c687cfb992c 100644 --- a/pcre2.spec +++ b/pcre2.spec @@ -1,6 +1,6 @@ Name: pcre2 Version: 10.39 -Release: 11 +Release: 12 Summary: Perl Compatible Regular Expressions License: BSD URL: http://www.pcre.org/ @@ -43,6 +43,8 @@ Patch6032: backport-Fix-compile-loop-in-32-bit-mode-for-characters-above.pat Patch6033: backport-Fix-incorrect-matching-of-0xffffffff-to-any-characte.patch Patch6034: backport-Fix-accept-and-endanchored-interaction-in-JIT.patch Patch6035: backport-Fix-backreferences-with-unset-backref-and-non-greedy.patch +Patch6036: backport-Sanity-checks-for-ctype-functions-342.patch +Patch6037: backport-Fix-incorrect-class-character-matches-in-JIT.patch BuildRequires: autoconf libtool automake coreutils gcc make readline-devel Obsoletes: pcre2-utf16 pcre2-utf32 pcre2-tools @@ -159,6 +161,10 @@ make check %{_pkgdocdir}/html/ %changelog +* Mon Feb 05 2024 xujing - 10.39-12 +- DESC:Sanity checks for ctype functions + Fix incorrect class character matches in JIT + * Mon Jan 22 2024 xujing - 10.39-11 - DESC:sync patches from upstream to fix some bugs