[Cmake-commits] CMake branch, next, updated. v3.1.0-1366-g4da208b

Brad King brad.king at kitware.com
Tue Dec 23 08:51:12 EST 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  4da208b7b12d28d6b71cda06158acdb6a64dc2d2 (commit)
       via  990df2f2a2f3e2b5f41db97636b96add07a282ab (commit)
      from  2a8f8d925fb30143c1a1f7ca22e125515e8c9c74 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4da208b7b12d28d6b71cda06158acdb6a64dc2d2
commit 4da208b7b12d28d6b71cda06158acdb6a64dc2d2
Merge: 2a8f8d9 990df2f
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Dec 23 08:51:11 2014 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Tue Dec 23 08:51:11 2014 -0500

    Merge topic 'base64-casts' into next
    
    990df2f2 CTest: Fix integer overflow when uploading huge files


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=990df2f2a2f3e2b5f41db97636b96add07a282ab
commit 990df2f2a2f3e2b5f41db97636b96add07a282ab
Author:     Rolf Eike Beer <eike at sf-mail.de>
AuthorDate: Mon Dec 22 21:56:14 2014 +0100
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Dec 23 08:49:54 2014 -0500

    CTest: Fix integer overflow when uploading huge files
    
    When uploading files greater 2GB a cast to 'int' overflows, leading to a
    bad alloc when passed to new. Also avoid floating point arithmetic when
    integer calculations will work as well.
    
    Reported-by: Justin Borodinsky <justin.borodinsky at gmail.com>

diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index 2bf7b77..1a7bf45 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);
+  const size_t len = cmSystemTools::FileLength(file);
   cmsys::ifstream ifs(file.c_str(), std::ios::in
 #ifdef _WIN32
     | std::ios::binary
@@ -1699,8 +1699,7 @@ 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
     = cmsysBase64_Encode(file_buffer, len, encoded_buffer, 1);

-----------------------------------------------------------------------

Summary of changes:


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list