From e6f55339ccf923390da1ea354631809acb2e3729 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sun, 26 Jul 2015 18:33:01 +0200 Subject: [PATCH 1/2] add new error constant PREG_JIT_STACKLIMIT_ERROR --- ext/pcre/php_pcre.c | 10 +++++++++- ext/pcre/tests/preg_match_error3.phpt | 10 ++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 ext/pcre/tests/preg_match_error3.phpt diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index 8e40f846732..e57bbd9e384 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -50,7 +50,8 @@ enum { PHP_PCRE_BACKTRACK_LIMIT_ERROR, PHP_PCRE_RECURSION_LIMIT_ERROR, PHP_PCRE_BAD_UTF8_ERROR, - PHP_PCRE_BAD_UTF8_OFFSET_ERROR + PHP_PCRE_BAD_UTF8_OFFSET_ERROR, + PHP_PCRE_JIT_STACKLIMIT_ERROR }; @@ -77,6 +78,12 @@ static void pcre_handle_exec_error(int pcre_code) /* {{{ */ case PCRE_ERROR_BADUTF8_OFFSET: preg_code = PHP_PCRE_BAD_UTF8_OFFSET_ERROR; break; + +#ifdef PCRE_STUDY_JIT_COMPILE + case PCRE_ERROR_JIT_STACKLIMIT: + preg_code = PHP_PCRE_JIT_STACKLIMIT_ERROR; + break; +#endif default: preg_code = PHP_PCRE_INTERNAL_ERROR; @@ -169,6 +176,7 @@ static PHP_MINIT_FUNCTION(pcre) REGISTER_LONG_CONSTANT("PREG_RECURSION_LIMIT_ERROR", PHP_PCRE_RECURSION_LIMIT_ERROR, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("PREG_BAD_UTF8_ERROR", PHP_PCRE_BAD_UTF8_ERROR, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("PREG_BAD_UTF8_OFFSET_ERROR", PHP_PCRE_BAD_UTF8_OFFSET_ERROR, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("PREG_JIT_STACKLIMIT_ERROR", PHP_PCRE_JIT_STACKLIMIT_ERROR, CONST_CS | CONST_PERSISTENT); REGISTER_STRING_CONSTANT("PCRE_VERSION", (char *)pcre_version(), CONST_CS | CONST_PERSISTENT); return SUCCESS; diff --git a/ext/pcre/tests/preg_match_error3.phpt b/ext/pcre/tests/preg_match_error3.phpt new file mode 100644 index 00000000000..05a9baab07f --- /dev/null +++ b/ext/pcre/tests/preg_match_error3.phpt @@ -0,0 +1,10 @@ +--TEST-- +Test preg_match() function : error conditions - jit stacklimit exhausted +--FILE-- + +--EXPECT-- +bool(false) +bool(true) From 6de470e0af72d20de88e7c7b4e025f4f6a452e17 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sun, 26 Jul 2015 22:47:12 +0200 Subject: [PATCH 2/2] fixed broken test --- sapi/cli/tests/006.phpt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sapi/cli/tests/006.phpt b/sapi/cli/tests/006.phpt index b86c8a3197f..1170ea217ac 100644 --- a/sapi/cli/tests/006.phpt +++ b/sapi/cli/tests/006.phpt @@ -39,7 +39,7 @@ string(%d) "Extension [ extension #%d pcre version %d.%d.%d%a ] { } } - - Constants [14] { + - Constants [15] { Constant [ integer PREG_PATTERN_ORDER ] { 1 } Constant [ integer PREG_SET_ORDER ] { 2 } Constant [ integer PREG_OFFSET_CAPTURE ] { 256 } @@ -53,6 +53,7 @@ string(%d) "Extension [ extension #%d pcre version %d.%d.%d%a ] { Constant [ integer PREG_RECURSION_LIMIT_ERROR ] { 3 } Constant [ integer PREG_BAD_UTF8_ERROR ] { 4 } Constant [ integer PREG_BAD_UTF8_OFFSET_ERROR ] { 5 } + Constant [ integer PREG_JIT_STACKLIMIT_ERROR ] { 6 } Constant [ string PCRE_VERSION ] { %s } }