]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Prevent integer overflows when computing configured cache_dir size.
authorAlex Rousskov <rousskov@measurement-factory.com>
Fri, 5 Aug 2011 17:02:10 +0000 (11:02 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Fri, 5 Aug 2011 17:02:10 +0000 (11:02 -0600)
src/fs/coss/store_dir_coss.cc
src/fs/rock/RockSwapDir.cc
src/fs/ufs/store_dir_ufs.cc

index dd9c07111e8a526c5fc96534765812b0e6de1c70..77564f164ab6d990afff29c41d3eeb6978c65aa9 100644 (file)
@@ -1008,7 +1008,7 @@ CossSwapDir::parse(int anIndex, char *aPath)
 
     path = xstrdup(aPath);
 
-    max_size = i << 20; // MBytes to Bytes
+    max_size = static_cast<uint64_t>(i) << 20; // MBytes to Bytes
 
     parseOptions(0);
 
@@ -1046,7 +1046,7 @@ CossSwapDir::reconfigure(int index, char *path)
     if (i <= 0)
         fatal("storeCossDirParse: invalid size value");
 
-    const uint64_t size = i << 20; // MBytes to Bytes
+    const uint64_t size = static_cast<uint64_t>(i) << 20; // MBytes to Bytes
 
     if (size == maxSize())
         debugs(3, 1, "Cache COSS dir '" << path << "' size remains unchanged at " << i << " MB");
index 2b6e81f4c5306838dc87e4a5794eacabc7f5909d..bf072156076052ca42f971715018b05742bbe68f 100644 (file)
@@ -276,7 +276,7 @@ Rock::SwapDir::parseSize()
     const int i = GetInteger();
     if (i < 0)
         fatal("negative Rock cache_dir size value");
-    max_size = i << 20; // MBytes to Bytes
+    max_size = static_cast<uint64_t>(i) << 20; // MBytes to Bytes
 }
 
 /// check the results of the configuration; only level-0 debugging works here
index f1014300aac558240f52facfa2a5640ffeca996e..47cd62eda193f3dba5b698dc1d129ada68a2e83f 100644 (file)
@@ -80,7 +80,7 @@ UFSSwapDir::parseSizeL1L2()
     if (i <= 0)
         fatal("UFSSwapDir::parseSizeL1L2: invalid size value");
 
-    const uint64_t size = i << 20; // MBytes to Bytes
+    const uint64_t size = static_cast<uint64_t>(i) << 20; // MBytes to Bytes
 
     /* just reconfigure it */
     if (reconfiguring) {