diff options
author | Stefan Fritsch <sf@apache.org> | 2012-05-27 23:40:00 +0200 |
---|---|---|
committer | Stefan Fritsch <sf@apache.org> | 2012-05-27 23:40:00 +0200 |
commit | a1b0be3dcba63937b705887299959ab83975eb75 (patch) | |
tree | 6d63beb9720a16f88c689d1f0c1a3081d7d68983 /server/util_pcre.c | |
parent | Compile the regex used by is_header_regex() only once during startup (diff) | |
download | apache2-a1b0be3dcba63937b705887299959ab83975eb75.tar.xz apache2-a1b0be3dcba63937b705887299959ab83975eb75.zip |
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.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1343109 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'server/util_pcre.c')
-rw-r--r-- | server/util_pcre.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/server/util_pcre.c b/server/util_pcre.c index 2d157c0c10..1e83cad080 100644 --- a/server/util_pcre.c +++ b/server/util_pcre.c @@ -123,6 +123,7 @@ AP_DECLARE(int) ap_regcomp(ap_regex_t * preg, const char *pattern, int cflags) { const char *errorptr; int erroffset; + int errcode = 0; int options = 0; if ((cflags & AP_REG_ICASE) != 0) @@ -133,11 +134,18 @@ AP_DECLARE(int) ap_regcomp(ap_regex_t * preg, const char *pattern, int cflags) 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)); |