diff options
author | Jeffrey Walton <noloader@gmail.com> | 2018-11-21 23:04:00 -0500 |
---|---|---|
committer | Jeffrey Walton <noloader@gmail.com> | 2018-11-21 23:04:00 -0500 |
commit | 6cf8895bf130b90daabd534527ce1a2a93fa20d0 (patch) | |
tree | c6cd4b98ce686204fd2a291badb75a7ad50bab2c /secblock.h | |
parent | 1e8ac49b4943e7272c186b4f81252daf6ce24979 (diff) | |
download | cryptopp-git-6cf8895bf130b90daabd534527ce1a2a93fa20d0.tar.gz |
Add additional assert to FixedSizeAllocatorWithCleanup (GH #745)
This assert checks the array we return to the caller is large enough. Spoiler alert... it is not always large enough, like on 64-bit AIX. The linker on AIX appears to align smaller than 8-bytes
Diffstat (limited to 'secblock.h')
-rw-r--r-- | secblock.h | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -500,7 +500,10 @@ private: // for a large T, and that is what PAD achieves.
T* GetAlignedArray() {
T* p_array = (T*)(void*)(((byte*)m_array) + (0-(size_t)m_array)%16);
+ // Verify the 16-byte alignment
CRYPTOPP_ASSERT(IsAlignedOn(p_array, 16));
+ // Verify allocated array with pad is large enough.
+ CRYPTOPP_ASSERT(p_array+S <= m_array+(S+PAD));
return p_array;
}
// PAD is elements, not bytes, and rounded up to ensure no overflow.
|