]> granicus.if.org Git - apache/commitdiff
Some good casts - mem_cache cannot overflow with LARGEFILE sized objects.
authorWilliam A. Rowe Jr <wrowe@apache.org>
Sat, 12 Oct 2002 16:12:14 +0000 (16:12 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Sat, 12 Oct 2002 16:12:14 +0000 (16:12 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@97189 13f79535-47bb-0310-9956-ffa450edef68

modules/experimental/mod_mem_cache.c

index 60d1768c2c36aa82411989465ae5cd3ac6e31f43..b5476eb9997608fb69b34202c15e115edffdb258 100644 (file)
@@ -484,7 +484,8 @@ static int create_entity(cache_handle_t *h, request_rec *r,
         return DECLINED;
     }
     memcpy(obj->key, key, key_len);
-    obj->info.len = len;
+    /* Safe cast: We tested < sconf->max_cache_object_size above */
+    obj->info.len = (apr_size_t)len;
 
 
     /* Allocate and init mem_cache_object_t */
@@ -504,7 +505,8 @@ static int create_entity(cache_handle_t *h, request_rec *r,
     obj->complete = 0;
     obj->cleanup = 0;
     obj->vobj = mobj;
-    mobj->m_len = len;
+    /* Safe cast: We tested < sconf->max_cache_object_size above */
+    mobj->m_len = (apr_size_t)len;
     mobj->type = type_e;
 
     /* Place the cache_object_t into the hash table.
@@ -527,7 +529,8 @@ static int create_entity(cache_handle_t *h, request_rec *r,
     if (!tmp_obj) {
         cache_insert(sconf->cache_cache, obj);     
         sconf->object_cnt++;
-        sconf->cache_size += len;
+        /* Safe cast: Must fit in cache_size or alloc would have failed */
+        sconf->cache_size += (apr_size_t)len;
     }
     if (sconf->lock) {
         apr_thread_mutex_unlock(sconf->lock);