From 75994d953e261b388aa31e4d8ecd8af9fe53142b Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 10 Jun 2013 16:52:16 -0400 Subject: cmCryptoHash: Increase alignment of HashFile buffer The SHA512_Update implementation accesses input data via 64-bit integers. This requires alignment of the input buffer on some architectures. Align our stack-allocated buffer for file content to satisfy this requirement. --- Source/cmCryptoHash.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/cmCryptoHash.cxx b/Source/cmCryptoHash.cxx index a1505bd..a4f6ac4 100644 --- a/Source/cmCryptoHash.cxx +++ b/Source/cmCryptoHash.cxx @@ -54,8 +54,8 @@ std::string cmCryptoHash::HashFile(const char* file) this->Initialize(); // Should be efficient enough on most system: - const int bufferSize = 4096; - char buffer[bufferSize]; + cm_sha2_uint64_t buffer[512]; + char* buffer_c = reinterpret_cast(buffer); unsigned char const* buffer_uc = reinterpret_cast(buffer); // This copy loop is very sensitive on certain platforms with @@ -65,7 +65,7 @@ std::string cmCryptoHash::HashFile(const char* file) // error occurred. Therefore, the loop should be safe everywhere. while(fin) { - fin.read(buffer, bufferSize); + fin.read(buffer_c, sizeof(buffer)); if(int gcount = static_cast(fin.gcount())) { this->Append(buffer_uc, gcount); -- cgit v0.12