httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r1194912 - /httpd/httpd/trunk/server/util.c
Date Sat, 29 Oct 2011 16:07:16 GMT
Author: jim
Date: Sat Oct 29 16:07:16 2011
New Revision: 1194912

URL: http://svn.apache.org/viewvc?rev=1194912&view=rev
Log:
Remove magic numbers; ensure that an invalid nmatch is corrected
tagged

Modified:
    httpd/httpd/trunk/server/util.c

Modified: httpd/httpd/trunk/server/util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util.c?rev=1194912&r1=1194911&r2=1194912&view=diff
==============================================================================
--- httpd/httpd/trunk/server/util.c (original)
+++ httpd/httpd/trunk/server/util.c Sat Oct 29 16:07:16 2011
@@ -382,9 +382,9 @@ static apr_status_t regsub_core(apr_pool
     apr_size_t len = 0;
 
     AP_DEBUG_ASSERT((result && p && !vb) || (vb && !p &&
!result));
-    if (!source)
+    if (!source || nmatch>AP_MAX_REG_MATCH)
         return APR_EINVAL;
-    if (!nmatch || nmatch>AP_MAX_REG_MATCH) {
+    if (!nmatch) {
         len = strlen(src);
         if (maxlen > 0 && len >= maxlen)
             return APR_ENOMEM;
@@ -405,7 +405,7 @@ static apr_status_t regsub_core(apr_pool
         else
             no = AP_MAX_REG_MATCH;
 
-        if (no > 9) {                /* Ordinary character. */
+        if (no >= AP_MAX_REG_MATCH) {  /* Ordinary character. */
             if (c == '\\' && *src)
                 src++;
             len++;
@@ -440,9 +440,9 @@ static apr_status_t regsub_core(apr_pool
         else if (c == '$' && apr_isdigit(*src))
             no = *src++ - '0';
         else
-            no = 10;
+            no = AP_MAX_REG_MATCH;
 
-        if (no > 9) {                /* Ordinary character. */
+        if (no >= AP_MAX_REG_MATCH) {  /* Ordinary character. */
             if (c == '\\' && (*src == '$' || *src == '&'))
                 c = *src++;
             *dst++ = c;
@@ -460,7 +460,7 @@ static apr_status_t regsub_core(apr_pool
 }
 
 #ifndef AP_PREGSUB_MAXLEN
-#define AP_PREGSUB_MAXLEN   65536
+#define AP_PREGSUB_MAXLEN   (HUGE_STRING_LEN * 8)
 #endif
 AP_DECLARE(char *) ap_pregsub(apr_pool_t *p, const char *input,
                               const char *source, size_t nmatch,



Mime
View raw message