]> granicus.if.org Git - apache/commitdiff
mod_disk_cache: Make sure that only positive integers are accepted
authorGraham Leggett <minfrin@apache.org>
Tue, 26 Sep 2006 13:29:09 +0000 (13:29 +0000)
committerGraham Leggett <minfrin@apache.org>
Tue, 26 Sep 2006 13:29:09 +0000 (13:29 +0000)
for the CacheMaxFileSize and CacheMinFileSize parameters in the
config file. PR39380 [Niklas Edmundsson <nikke acc.umu.se>]

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

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

diff --git a/CHANGES b/CHANGES
index 4f10cdb39c77ce469ea568b9494780e5bc8c0591..192ea62c2bc2e7a189a326357fb76f5488d23356 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,10 @@
 Changes with Apache 2.3.0
   [Remove entries to the current 2.0 and 2.2 section below, when backported]
 
+  *) 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_proxy_balancer: Set the new environment variable BALANCER_ROUTE_CHANGED
      if a worker with a route different from the one supplied by the client
      had been chosen or if the client supplied no routing information for
index 6d52359a9c2dfa91d26c0c33bc5579e4b90a907d..f89a65828a692cc8d0737444c3b13cc697c36f80 100644 (file)
@@ -334,14 +334,14 @@ static int create_entity(cache_handle_t *h, request_rec *r, const char *key, apr
     if (len > conf->maxfs) {
         ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
                      "disk_cache: URL %s failed the size check "
-                     "(%" APR_OFF_T_FMT " > %" APR_SIZE_T_FMT ")",
+                     "(%" APR_OFF_T_FMT " > %" APR_OFF_T_FMT ")",
                      key, len, conf->maxfs);
         return DECLINED;
     }
     if (len >= 0 && len < conf->minfs) {
         ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
                      "disk_cache: URL %s failed the size check "
-                     "(%" APR_OFF_T_FMT " < %" APR_SIZE_T_FMT ")",
+                     "(%" APR_OFF_T_FMT " < %" APR_OFF_T_FMT ")",
                      key, len, conf->minfs);
         return DECLINED;
     }
@@ -1026,7 +1026,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,
                          "disk_cache: 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);
@@ -1050,7 +1050,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,
                          "disk_cache: 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);
@@ -1137,15 +1137,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*/