com php-src: added range check for pcre ini entries: ext/pcre/php_pcre.c ext/pcre/php_pcre.h
| From: | Anatol Belski | Date: | Thu, 05 Dec 2013 11:08:19 +0000 |
| Subject: | com php-src: added range check for pcre ini entries: ext/pcre/php_pcre.c ext/pcre/php_pcre.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-74254@lists.php.net to get a copy of this message | ||
Commit: 4d703a4225977b0c6abb2f88c2fe56732d6452a1
Author: Anatol Belski <ab@php.net> Thu, 5 Dec 2013 12:08:19 +0100
Parents: a0622d7c68f3b55068053aaa089f854ec59cb698
Branches: str_size_and_int64
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=4d703a4225977b0c6abb2f88c2fe56732d6452a1
Log:
added range check for pcre ini entries
Changed paths:
M ext/pcre/php_pcre.c
M ext/pcre/php_pcre.h
Diff:
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
index 3daa8e8..05dad38 100644
--- a/ext/pcre/php_pcre.c
+++ b/ext/pcre/php_pcre.c
@@ -114,9 +114,41 @@ static PHP_GSHUTDOWN_FUNCTION(pcre) /* {{{ */
}
/* }}} */
+static PHP_INI_MH(OnChangeBacktrackLimit)
+{/*{{{*/
+ php_int_t i;
+
+ ZEND_ATOI(i, new_value);
+
+ if (i > (unsigned long)-1) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Value '%pd' is too big for
pcre.backtrack_limit", i);
+ return FAILURE;
+ }
+
+ PCRE_G(backtrack_limit) = i;
+
+ return SUCCESS;
+}/*}}}*/
+
+static PHP_INI_MH(OnChangeRecursionLimit)
+{/*{{{*/
+ php_int_t i;
+
+ ZEND_ATOI(i, new_value);
+
+ if (i > (unsigned long)-1) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Value '%pd' is too big for
pcre.recursion_limit", i);
+ return FAILURE;
+ }
+
+ PCRE_G(recursion_limit) = i;
+
+ return SUCCESS;
+}/*}}}*/
+
PHP_INI_BEGIN()
- STD_PHP_INI_ENTRY("pcre.backtrack_limit", "1000000", PHP_INI_ALL,
OnUpdateLong, backtrack_limit, zend_pcre_globals, pcre_globals)
- STD_PHP_INI_ENTRY("pcre.recursion_limit", "100000", PHP_INI_ALL, OnUpdateLong,
recursion_limit, zend_pcre_globals, pcre_globals)
+ PHP_INI_ENTRY("pcre.backtrack_limit", "1000000", PHP_INI_ALL,
OnChangeBacktrackLimit)
+ PHP_INI_ENTRY("pcre.recursion_limit", "100000", PHP_INI_ALL,
OnChangeRecursionLimit)
PHP_INI_END()
diff --git a/ext/pcre/php_pcre.h b/ext/pcre/php_pcre.h
index 5a94360..26d2756 100644
--- a/ext/pcre/php_pcre.h
+++ b/ext/pcre/php_pcre.h
@@ -68,8 +68,8 @@ PHPAPI void php_pcre_grep_impl( pcre_cache_entry *pce, zval *input, zval *ret
ZEND_BEGIN_MODULE_GLOBALS(pcre)
HashTable pcre_cache;
- long backtrack_limit;
- long recursion_limit;
+ php_int_t backtrack_limit;
+ php_int_t recursion_limit;
int error_code;
ZEND_END_MODULE_GLOBALS(pcre)