From 2347782f6ae0fe804241e183b02d9d04b5ee6da6 Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Mon, 15 Feb 2016 05:00:30 +0100 Subject: [PATCH] Fix test cases for Release builds: The -O3 optimization step seems to cause segfaults on implicit integer overflows, so make the wanted overflows explicit in FakeAuthenticatedCipher. --- .../crypto/symmetric/testutils/FakeAuthenticatedCipher.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/cpp-utils/crypto/symmetric/testutils/FakeAuthenticatedCipher.h b/test/cpp-utils/crypto/symmetric/testutils/FakeAuthenticatedCipher.h index 2aa9b8fc..cb8bf34a 100644 --- a/test/cpp-utils/crypto/symmetric/testutils/FakeAuthenticatedCipher.h +++ b/test/cpp-utils/crypto/symmetric/testutils/FakeAuthenticatedCipher.h @@ -90,14 +90,14 @@ namespace cpputils { private: static int32_t _parity(const byte *data, unsigned int size) { int32_t parity = 34343435; // some init value - int32_t *intData = (int32_t *) data; + const int32_t *intData = reinterpret_cast(data); unsigned int intSize = size / sizeof(int32_t); for (unsigned int i = 0; i < intSize; ++i) { - parity += intData[i]; + parity = ((int64_t)parity) + intData[i]; } unsigned int remainingBytes = size - 4 * intSize; for (unsigned int i = 0; i < remainingBytes; ++i) { - parity += (data[4 * intSize + i] << (24 - 8 * i)); + parity = ((int64_t)parity) + (data[4 * intSize + i] << (24 - 8 * i)); } return parity; }