]> granicus.if.org Git - apache/commitdiff
Only allow parens in filename if cachesize is given. Return error otherwise
authorStefan Fritsch <sf@apache.org>
Sat, 24 Oct 2009 13:29:03 +0000 (13:29 +0000)
committerStefan Fritsch <sf@apache.org>
Sat, 24 Oct 2009 13:29:03 +0000 (13:29 +0000)
to catch missing parens.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@829362 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/cache/mod_socache_shmcb.c

diff --git a/CHANGES b/CHANGES
index c9694e600c5189d9577c1fa960b93951566f2b52..5a147e51e85fa93f684fe31858fff0d9a8e70a45 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -10,8 +10,8 @@ Changes with Apache 2.3.3
      mod_proxy_ftp: NULL pointer dereference on error paths.
      [Stefan Fritsch <sf fritsch.de>, Joe Orton]
 
-  *) mod_socache_shmcb: Only parse cache size in parens at the end of the
-     string. Fixes SSLSessionCache directive mis-parsing parens in pathname.
+  *) mod_socache_shmcb: Allow parens in file name if cache size is given.
+     Fixes SSLSessionCache directive mis-parsing parens in pathname.
      PR 47945. [Stefan Fritsch]
 
   *) htpasswd: Improve out of disk space handling. PR 30877. [Stefan Fritsch]
index b9d688f62d16d6c92fe5c9ed339a83c9e05bf67c..4000939ec25a44f31126cabf0478a2c5815f5d01 100644 (file)
@@ -280,11 +280,20 @@ static const char *socache_shmcb_create(ap_socache_instance_t **context,
 
     cp = strrchr(path, '(');
     cp2 = path + strlen(path) - 1;
-    if (cp && (*cp2 == ')')) {
+    if (cp) {
+        char *endptr;
+        if (*cp2 != ')') {
+            return "Invalid argument: no closing parenthesis or cache size "
+                   "missing after pathname with parenthesis";
+        }
         *cp++ = '\0';
         *cp2  = '\0';
         
-        ctx->shm_size = atoi(cp);
+        
+        ctx->shm_size = strtol(cp, &endptr, 10);
+        if (endptr != cp2) {
+            return "Invalid argument: cache size not numerical";
+        }
         
         if (ctx->shm_size < 8192) {
             return "Invalid argument: size has to be >= 8192 bytes";
@@ -299,6 +308,9 @@ static const char *socache_shmcb_create(ap_socache_instance_t **context,
             
         }
     }
+    else if (cp2 >= path && *cp2 == ')') {
+        return "Invalid argument: no opening parenthesis";
+    }
 
     return NULL;
 }