httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s.@apache.org
Subject svn commit: r1343109 - in /httpd/httpd/trunk: CHANGES configure.in server/util.c server/util_pcre.c
Date Sun, 27 May 2012 21:40:01 GMT
Author: sf
Date: Sun May 27 21:40:00 2012
New Revision: 1343109

URL: http://svn.apache.org/viewvc?rev=1343109&view=rev
Log:
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.

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/configure.in
    httpd/httpd/trunk/server/util.c
    httpd/httpd/trunk/server/util_pcre.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1343109&r1=1343108&r2=1343109&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Sun May 27 21:40:00 2012
@@ -1,6 +1,10 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.5.0
 
+  *) 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]
+
   *) apxs: Use LDFLAGS from config_vars.mk in addition to CFLAGS and CPPFLAGS.
      [Stefan Fritsch]
 

Modified: httpd/httpd/trunk/configure.in
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/configure.in?rev=1343109&r1=1343108&r2=1343109&view=diff
==============================================================================
--- httpd/httpd/trunk/configure.in (original)
+++ httpd/httpd/trunk/configure.in Sun May 27 21:40:00 2012
@@ -225,6 +225,11 @@ if test "$PCRE_CONFIG" != "false"; then
   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`])

Modified: httpd/httpd/trunk/server/util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util.c?rev=1343109&r1=1343108&r2=1343109&view=diff
==============================================================================
--- httpd/httpd/trunk/server/util.c (original)
+++ httpd/httpd/trunk/server/util.c Sun May 27 21:40:00 2012
@@ -273,8 +273,10 @@ AP_DECLARE(ap_regex_t *) ap_pregcomp(apr
                                      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;
     }
 

Modified: httpd/httpd/trunk/server/util_pcre.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util_pcre.c?rev=1343109&r1=1343108&r2=1343109&view=diff
==============================================================================
--- httpd/httpd/trunk/server/util_pcre.c (original)
+++ httpd/httpd/trunk/server/util_pcre.c Sun May 27 21:40:00 2012
@@ -123,6 +123,7 @@ AP_DECLARE(int) ap_regcomp(ap_regex_t * 
 {
     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 * 
         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));



Mime
View raw message