]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
mod_disk_cache: Make sure that only positive integers are accepted
authorGraham Leggett <minfrin@apache.org>
Thu, 12 Oct 2006 23:17:43 +0000 (23:17 +0000)
committerGraham Leggett <minfrin@apache.org>
Thu, 12 Oct 2006 23:17:43 +0000 (23:17 +0000)
for the CacheMaxFileSize and CacheMinFileSize parameters in the
config file. PR39380

+1: minfrin, jim, trawick

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@463506 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
STATUS
modules/cache/mod_disk_cache.c
modules/cache/mod_disk_cache.h

diff --git a/CHANGES b/CHANGES
index e664540e790a57a72e8ab7dbc17fb9bd1517f520..28b8ce21860fa9715fc2a92e72a8b317517701c2 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,10 @@
                                                         -*- coding: utf-8 -*-
 Changes with Apache 2.2.4
 
+  *) mod_disk_cache: Make sure that only positive integers are accepted
+     for the CacheMaxFileSize and CacheMinFileSize parameters in the
+     config file. PR39380 [Niklas Edmundsson <nikke acc.umu.se>]
+
   *) mod_cache: From RFC3986 (section 6.2.3.) if a URI contains an
      authority component and an empty path, the empty path is to be equivalent
      to "/". It explicitly cites the following four URIs as equivalents:
diff --git a/STATUS b/STATUS
index 79397fd9671001040b24485732cdad8b0d726717..150d9b6a0640ce2f1c73686cca6d46746d6cf48d 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -77,22 +77,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-    * mod_cache: From RFC3986 (section 6.2.3.) if a URI contains an
-      authority component and an empty path, the empty path is to be equivalent
-      to "/". It explicitly cites the following four URIs as equivalents:
-        http://example.com
-        http://example.com/
-        http://example.com:/
-        http://example.com:80/
-      Trunk: http://svn.apache.org/viewvc?view=rev&revision=450063
-      +1: minfrin, rpluem, jim
-
-    * mod_disk_cache: Make sure that only positive integers are accepted
-      for the CacheMaxFileSize and CacheMinFileSize parameters in the
-      config file. PR39380
-      Trunk: http://svn.apache.org/viewvc?view=rev&revision=450042
-      2.2.x: http://people.apache.org/~minfrin/mod_disk_cache-lfsconfig-2.2.patch
-      +1: minfrin, jim, trawick
 
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
 
index 15e333c0e0d49f2ee216e8f0d0f515f4f61a94f0..92c5ad7501bf489a1113eccfc071d5f4eb81eedd 100644 (file)
@@ -1006,7 +1006,7 @@ static apr_status_t store_body(cache_handle_t *h, request_rec *r,
         if (dobj->file_size > conf->maxfs) {
             ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
                          "cache_disk: URL %s failed the size check "
-                         "(%" APR_OFF_T_FMT ">%" APR_SIZE_T_FMT ")",
+                         "(%" APR_OFF_T_FMT " > %" APR_OFF_T_FMT ")",
                          h->cache_obj->key, dobj->file_size, conf->maxfs);
             /* Remove the intermediate cache file and return non-APR_SUCCESS */
             file_cache_errorcleanup(dobj, r);
@@ -1030,7 +1030,7 @@ static apr_status_t store_body(cache_handle_t *h, request_rec *r,
         if (dobj->file_size < conf->minfs) {
             ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
                          "cache_disk: URL %s failed the size check "
-                         "(%" APR_OFF_T_FMT "<%" APR_SIZE_T_FMT ")",
+                         "(%" APR_OFF_T_FMT " < %" APR_OFF_T_FMT ")",
                          h->cache_obj->key, dobj->file_size, conf->minfs);
             /* Remove the intermediate cache file and return non-APR_SUCCESS */
             file_cache_errorcleanup(dobj, r);
@@ -1117,15 +1117,25 @@ static const char
 {
     disk_cache_conf *conf = ap_get_module_config(parms->server->module_config,
                                                  &disk_cache_module);
-    conf->minfs = atoi(arg);
+
+    if (apr_strtoff(&conf->minfs, arg, NULL, 0) != APR_SUCCESS ||
+            conf->minfs < 0) 
+    {
+        return "CacheMinFileSize argument must be a non-negative integer representing the min size of a file to cache in bytes.";
+    }
     return NULL;
 }
+
 static const char
 *set_cache_maxfs(cmd_parms *parms, void *in_struct_ptr, const char *arg)
 {
     disk_cache_conf *conf = ap_get_module_config(parms->server->module_config,
                                                  &disk_cache_module);
-    conf->maxfs = atoi(arg);
+    if (apr_strtoff(&conf->maxfs, arg, NULL, 0) != APR_SUCCESS ||
+            conf->maxfs < 0) 
+    {
+        return "CacheMaxFileSize argument must be a non-negative integer representing the max size of a file to cache in bytes.";
+    }
     return NULL;
 }
 
index d9911795e7fb3e0a0de44e68b54cb816c099af66..3c03554300643c1a6a3e42d8e517bdf783c61730 100644 (file)
@@ -88,8 +88,8 @@ typedef struct {
     apr_size_t cache_root_len;
     int dirlevels;               /* Number of levels of subdirectories */
     int dirlength;               /* Length of subdirectory names */
-    apr_size_t minfs;            /* minumum file size for cached files */
-    apr_size_t maxfs;            /* maximum file size for cached files */
+    apr_off_t minfs;             /* minimum file size for cached files */
+    apr_off_t maxfs;             /* maximum file size for cached files */
 } disk_cache_conf;
 
 #endif /*MOD_DISK_CACHE_H*/