Make ap_regcomp() return AP_REG_ESPACE if out of memory. Make ap_pregcomp()
abort if out of memory.
This raises the minimum PCRE requirement to version 6.0, released in 2005.
Reviewed by: jim, sf, minfrin
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@
1418930 13f79535-47bb-0310-9956-
ffa450edef68
Changes with Apache 2.4.4
+ *) core: Make ap_regcomp() return AP_REG_ESPACE if out of memory. Make
+ ap_pregcomp() abort if out of memory. This raises the minimum PCRE
+ requirement to version 6.0. [Stefan Fritsch]
+
*) mod_proxy: Add ability to configure the sticky session separator.
PR 53893. [<inu inusasha de>, Jim Jagielski]
PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
[ start all new proposals below, under PATCHES PROPOSED. ]
- * core: Make ap_regcomp() return AP_REG_ESPACE if out of memory.
- Make ap_pregcomp() abort if out of memory. This raises the minimum
- PCRE requirement to version 6.0, released in 2005.
- trunk patch: http://svn.apache.org/viewvc?view=revision&revision=1343109
- 2.4.x patch: trunk patch works
- +1: jim, sf, minfrin
-
* util: make varbuf functions treat AP_VARBUF_UNKNOWN consistently
trunk patch: http://svn.apache.org/viewvc?view=revision&revision=1359884
2.4.x patch: trunk patch works
if $PCRE_CONFIG --version >/dev/null 2>&1; then :; else
AC_MSG_ERROR([Did not find pcre-config script at $PCRE_CONFIG])
fi
+ case `$PCRE_CONFIG --version` in
+ [[1-5].*])
+ AC_MSG_ERROR([Need at least pcre version 6.0])
+ ;;
+ esac
AC_MSG_NOTICE([Using external PCRE library from $PCRE_CONFIG])
APR_ADDTO(PCRE_INCLUDES, [`$PCRE_CONFIG --cflags`])
APR_ADDTO(PCRE_LIBS, [`$PCRE_CONFIG --libs`])
int cflags)
{
ap_regex_t *preg = apr_palloc(p, sizeof *preg);
-
- if (ap_regcomp(preg, pattern, cflags)) {
+ int err = ap_regcomp(preg, pattern, cflags);
+ if (err) {
+ if (err == AP_REG_ESPACE)
+ ap_abort_on_oom();
return NULL;
}
{
const char *errorptr;
int erroffset;
+ int errcode = 0;
int options = 0;
if ((cflags & AP_REG_ICASE) != 0)
options |= PCRE_DOTALL;
preg->re_pcre =
- pcre_compile(pattern, options, &errorptr, &erroffset, NULL);
+ pcre_compile2(pattern, options, &errcode, &errorptr, &erroffset, NULL);
preg->re_erroffset = erroffset;
- if (preg->re_pcre == NULL)
+ if (preg->re_pcre == NULL) {
+ /*
+ * There doesn't seem to be constants defined for compile time error
+ * codes. 21 is "failed to get memory" according to pcreapi(3).
+ */
+ if (errcode == 21)
+ return AP_REG_ESPACE;
return AP_REG_INVARG;
+ }
pcre_fullinfo((const pcre *)preg->re_pcre, NULL,
PCRE_INFO_CAPTURECOUNT, &(preg->re_nsub));