summaryrefslogtreecommitdiffstats
path: root/Source/cmCTest.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-01-08 19:57:41 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2015-01-08 19:57:41 (GMT)
commitdc451574c67da688024d5f3686c7c2aa4c5040ba (patch)
tree407db74b018131fee19cc6340d008490f3b1f733 /Source/cmCTest.cxx
parent9bb7f8f8982d1d73ca4d4ee108f3f2505e01ee7e (diff)
parent0bdd4ebfb8303cc46e4a8bbe16f6c7bcc7108e2a (diff)
downloadCMake-dc451574c67da688024d5f3686c7c2aa4c5040ba.zip
CMake-dc451574c67da688024d5f3686c7c2aa4c5040ba.tar.gz
CMake-dc451574c67da688024d5f3686c7c2aa4c5040ba.tar.bz2
Merge topic 'base64-casts'
0bdd4ebf cmCTest: Use size_t for cmsysBase64_Encode return value a9fae8ac CTest: Fix integer overflow when uploading huge files
Diffstat (limited to 'Source/cmCTest.cxx')
-rw-r--r--Source/cmCTest.cxx13
1 files changed, 6 insertions, 7 deletions
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index 80dbaf3..2f1cf10 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -1688,7 +1688,7 @@ std::string cmCTest::Base64GzipEncodeFile(std::string file)
//----------------------------------------------------------------------
std::string cmCTest::Base64EncodeFile(std::string file)
{
- long len = cmSystemTools::FileLength(file);
+ size_t const len = cmSystemTools::FileLength(file);
cmsys::ifstream ifs(file.c_str(), std::ios::in
#ifdef _WIN32
| std::ios::binary
@@ -1699,14 +1699,13 @@ std::string cmCTest::Base64EncodeFile(std::string file)
ifs.close();
unsigned char *encoded_buffer
- = new unsigned char [ static_cast<int>(
- static_cast<double>(len) * 1.5 + 5.0) ];
+ = new unsigned char [ (len * 3) / 2 + 5 ];
- unsigned long rlen
+ size_t const rlen
= cmsysBase64_Encode(file_buffer, len, encoded_buffer, 1);
std::string base64 = "";
- for(unsigned long i = 0; i < rlen; i++)
+ for(size_t i = 0; i < rlen; i++)
{
base64 += encoded_buffer[i];
}
@@ -3190,9 +3189,9 @@ bool cmCTest::CompressString(std::string& str)
// Now base64 encode the resulting binary string
unsigned char* base64EncodedBuffer
- = new unsigned char[static_cast<int>(outSize * 1.5)];
+ = new unsigned char[(outSize * 3) / 2];
- unsigned long rlen
+ size_t rlen
= cmsysBase64_Encode(out, strm.total_out, base64EncodedBuffer, 1);
str = "";