summaryrefslogtreecommitdiff
path: root/secblock.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2018-11-21 23:04:00 -0500
committerJeffrey Walton <noloader@gmail.com>2018-11-21 23:04:00 -0500
commit6cf8895bf130b90daabd534527ce1a2a93fa20d0 (patch)
treec6cd4b98ce686204fd2a291badb75a7ad50bab2c /secblock.h
parent1e8ac49b4943e7272c186b4f81252daf6ce24979 (diff)
downloadcryptopp-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.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/secblock.h b/secblock.h
index a9e350a6..4ad7c381 100644
--- a/secblock.h
+++ b/secblock.h
@@ -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.