From 2d9aabd6b1dfc70d59fc03cd7c62194be1ff0cdf Mon Sep 17 00:00:00 2001 From: zherczeg Date: Tue, 19 Nov 2019 12:25:32 +0000 Subject: [PATCH] Fixed the incorrect computation of jump sizes on x86 CPUs in JIT. --- ChangeLog | 3 +++ src/pcre2_jit_test.c | 2 ++ src/sljit/sljitNativeX86_common.c | 1 + 3 files changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index 27033ae..f3e3ba2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -182,6 +182,9 @@ caseless match, the "first code unit" optimization did not get the casing right, and the assertion failed to match a character in the other case if it did not start with the same code unit. +39. Fixed the incorrect computation of jump sizes on x86 CPUs in JIT. A masking +operation was incorrectly removed in r1136. Reported by Ralf Junker. + Version 10.33 16-April-2019 --------------------------- diff --git a/src/pcre2_jit_test.c b/src/pcre2_jit_test.c index 65f40bd..a9b3880 100644 --- a/src/pcre2_jit_test.c +++ b/src/pcre2_jit_test.c @@ -196,6 +196,8 @@ static struct regression_test_case regression_test_cases[] = { { CMUP, A, 0, 0, "\xf0\x90\x90\xa8{2}", "\xf0\x90\x90\x80#\xf0\x90\x90\xa8\xf0\x90\x90\x80" }, { CMUP, A, 0, 0, "\xe1\xbd\xb8\xe1\xbf\xb8", "\xe1\xbf\xb8\xe1\xbd\xb8" }, { M, A, 0, 0, "[3-57-9]", "5" }, + { PCRE2_AUTO_CALLOUT, A, 0, 0, "12345678901234567890123456789012345678901234567890123456789012345678901234567890", + "12345678901234567890123456789012345678901234567890123456789012345678901234567890" }, /* Assertions. */ { MU, A, 0, 0, "\\b[^A]", "A_B#" }, diff --git a/src/sljit/sljitNativeX86_common.c b/src/sljit/sljitNativeX86_common.c index 26e8475..6296da5 100644 --- a/src/sljit/sljitNativeX86_common.c +++ b/src/sljit/sljitNativeX86_common.c @@ -2515,6 +2515,7 @@ SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compile jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump)); PTR_FAIL_IF_NULL(jump); set_jump(jump, compiler, (type & SLJIT_REWRITABLE_JUMP) | ((type & 0xff) << TYPE_SHIFT)); + type &= 0xff; /* Worst case size. */ #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)