From 29653da385f89dcf00ebbb6823a395e1484d4dc3 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Fri, 7 Jul 2017 09:54:21 +0300 Subject: [PATCH] Fixed bug #74873 (Minor BC break: PCRE_JIT changes output of preg_match()). --- NEWS | 4 ++++ ext/pcre/php_pcre.c | 4 ++++ ext/pcre/tests/bug74873.phpt | 8 ++++++++ 3 files changed, 16 insertions(+) create mode 100644 ext/pcre/tests/bug74873.phpt diff --git a/NEWS b/NEWS index 96726feb6a..8a05976893 100644 --- a/NEWS +++ b/NEWS @@ -21,6 +21,10 @@ PHP NEWS . Fixed bug #74651 (negative-size-param (-1) in memcpy in zif_openssl_seal()). (Stas) +- PCRE: + . Fixed bug #74873 (Minor BC break: PCRE_JIT changes output of preg_match()). + (Dmitry) + 06 Jul 2017, PHP 7.2.0alpha3 - Core: diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index 5b07951c63..9779afaa36 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -826,6 +826,10 @@ PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, char *subject, int subjec #ifdef HAVE_PCRE_JIT_SUPPORT if ((extra->flags & PCRE_EXTRA_EXECUTABLE_JIT) && no_utf_check && !g_notempty) { + if (start_offset < 0 || start_offset > subject_len) { + pcre_handle_exec_error(PCRE_ERROR_BADOFFSET); + break; + } count = pcre_jit_exec(pce->re, extra, subject, (int)subject_len, (int)start_offset, no_utf_check|g_notempty, offsets, size_offsets, jit_stack); } else diff --git a/ext/pcre/tests/bug74873.phpt b/ext/pcre/tests/bug74873.phpt new file mode 100644 index 0000000000..9b64dae926 --- /dev/null +++ b/ext/pcre/tests/bug74873.phpt @@ -0,0 +1,8 @@ +--TEST-- +Bug #74873 (Minor BC break: PCRE_JIT changes output of preg_match()) +--FILE-- + +--EXPECT-- +bool(false) \ No newline at end of file -- 2.50.1