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