]> granicus.if.org Git - php/commitdiff
Fixed bug #74873 (Minor BC break: PCRE_JIT changes output of preg_match()).
authorDmitry Stogov <dmitry@zend.com>
Fri, 7 Jul 2017 06:54:21 +0000 (09:54 +0300)
committerDmitry Stogov <dmitry@zend.com>
Fri, 7 Jul 2017 06:54:21 +0000 (09:54 +0300)
NEWS
ext/pcre/php_pcre.c
ext/pcre/tests/bug74873.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 96726feb6a9ecc08cf0fd6f5d41b450819b915b8..8a05976893c4c9a0a84ebdce489fe4a1a4b1f91b 100644 (file)
--- 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:
index 5b07951c63e2e40bc51a20797a8051425f8e878b..9779afaa3668e51b3eece8d52fd69d7887ab093b 100644 (file)
@@ -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 (file)
index 0000000..9b64dae
--- /dev/null
@@ -0,0 +1,8 @@
+--TEST--
+Bug #74873 (Minor BC break: PCRE_JIT changes output of preg_match())
+--FILE--
+<?php
+var_dump(preg_match('/\S+/', 'foo bar', $matches, 0, 99999));
+?>
+--EXPECT--
+bool(false)
\ No newline at end of file