From: Alex Rousskov Date: Fri, 5 Aug 2011 17:02:10 +0000 (-0600) Subject: Prevent integer overflows when computing configured cache_dir size. X-Git-Tag: take08~56 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a0a5b16124997bd956d83941816904ed17482509;p=thirdparty%2Fsquid.git Prevent integer overflows when computing configured cache_dir size. --- diff --git a/src/fs/coss/store_dir_coss.cc b/src/fs/coss/store_dir_coss.cc index dd9c07111e..77564f164a 100644 --- a/src/fs/coss/store_dir_coss.cc +++ b/src/fs/coss/store_dir_coss.cc @@ -1008,7 +1008,7 @@ CossSwapDir::parse(int anIndex, char *aPath) path = xstrdup(aPath); - max_size = i << 20; // MBytes to Bytes + max_size = static_cast(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(i) << 20; // MBytes to Bytes if (size == maxSize()) debugs(3, 1, "Cache COSS dir '" << path << "' size remains unchanged at " << i << " MB"); diff --git a/src/fs/rock/RockSwapDir.cc b/src/fs/rock/RockSwapDir.cc index 2b6e81f4c5..bf07215607 100644 --- a/src/fs/rock/RockSwapDir.cc +++ b/src/fs/rock/RockSwapDir.cc @@ -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(i) << 20; // MBytes to Bytes } /// check the results of the configuration; only level-0 debugging works here diff --git a/src/fs/ufs/store_dir_ufs.cc b/src/fs/ufs/store_dir_ufs.cc index f1014300aa..47cd62eda1 100644 --- a/src/fs/ufs/store_dir_ufs.cc +++ b/src/fs/ufs/store_dir_ufs.cc @@ -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(i) << 20; // MBytes to Bytes /* just reconfigure it */ if (reconfiguring) {