summaryrefslogtreecommitdiff
path: root/zinflate.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2016-09-16 11:27:15 -0400
committerJeffrey Walton <noloader@gmail.com>2016-09-16 11:27:15 -0400
commit399a1546de71f41598c15edada28e7f0d616f541 (patch)
tree530160789358a3303be180df2d8529c82782156b /zinflate.cpp
parentfca5fbb36169a7522e6c533df9c322d47e3dc6bb (diff)
downloadcryptopp-git-399a1546de71f41598c15edada28e7f0d616f541.tar.gz
Add CRYPTOPP_ASSERT (Issue 277, CVE-2016-7420)
trap.h and CRYPTOPP_ASSERT has existed for over a year in Master. We deferred on the cut-over waiting for a minor version bump (5.7). We have to use it now due to CVE-2016-7420
Diffstat (limited to 'zinflate.cpp')
-rw-r--r--zinflate.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/zinflate.cpp b/zinflate.cpp
index adffca01..da473f35 100644
--- a/zinflate.cpp
+++ b/zinflate.cpp
@@ -32,20 +32,20 @@ inline bool LowFirstBitReader::FillBuffer(unsigned int length)
m_buffer |= (unsigned long)b << m_bitsBuffered;
m_bitsBuffered += 8;
}
- assert(m_bitsBuffered <= sizeof(unsigned long)*8);
+ CRYPTOPP_ASSERT(m_bitsBuffered <= sizeof(unsigned long)*8);
return true;
}
inline unsigned long LowFirstBitReader::PeekBits(unsigned int length)
{
bool result = FillBuffer(length);
- CRYPTOPP_UNUSED(result); assert(result);
+ CRYPTOPP_UNUSED(result); CRYPTOPP_ASSERT(result);
return m_buffer & (((unsigned long)1 << length) - 1);
}
inline void LowFirstBitReader::SkipBits(unsigned int length)
{
- assert(m_bitsBuffered >= length);
+ CRYPTOPP_ASSERT(m_bitsBuffered >= length);
m_buffer >>= length;
m_bitsBuffered -= length;
}
@@ -141,10 +141,10 @@ void HuffmanDecoder::Initialize(const unsigned int *codeBits, unsigned int nCode
m_cacheBits = STDMIN(9U, m_maxCodeBits);
m_cacheMask = (1 << m_cacheBits) - 1;
m_normalizedCacheMask = NormalizeCode(m_cacheMask, m_cacheBits);
- assert(m_normalizedCacheMask == BitReverse(m_cacheMask));
+ CRYPTOPP_ASSERT(m_normalizedCacheMask == BitReverse(m_cacheMask));
const word64 shiftedCache = ((word64)1 << m_cacheBits);
- assert(shiftedCache <= SIZE_MAX);
+ CRYPTOPP_ASSERT(shiftedCache <= SIZE_MAX);
if (m_cache.size() != shiftedCache)
m_cache.resize((size_t)shiftedCache);
@@ -181,7 +181,7 @@ void HuffmanDecoder::FillCacheEntry(LookupEntry &entry, code_t normalizedCode) c
inline unsigned int HuffmanDecoder::Decode(code_t code, /* out */ value_t &value) const
{
- assert(m_codeToValue.size() > 0);
+ CRYPTOPP_ASSERT(m_codeToValue.size() > 0);
LookupEntry &entry = m_cache[code & m_cacheMask];
code_t normalizedCode = 0;
@@ -209,7 +209,7 @@ inline unsigned int HuffmanDecoder::Decode(code_t code, /* out */ value_t &value
bool HuffmanDecoder::Decode(LowFirstBitReader &reader, value_t &value) const
{
bool result = reader.FillBuffer(m_maxCodeBits);
- CRYPTOPP_UNUSED(result); // assert(result);
+ CRYPTOPP_UNUSED(result); // CRYPTOPP_ASSERT(result);
unsigned int codeBits = Decode(reader.PeekBuffer(), value);
if (codeBits > reader.BitsBuffered())
@@ -478,13 +478,13 @@ bool Inflator::DecodeBody()
switch (m_blockType)
{
case 0: // stored
- assert(m_reader.BitsBuffered() == 0);
+ CRYPTOPP_ASSERT(m_reader.BitsBuffered() == 0);
while (!m_inQueue.IsEmpty() && !blockEnd)
{
size_t size;
const byte *block = m_inQueue.Spy(size);
size = UnsignedMin(m_storedLen, size);
- assert(size <= 0xffff);
+ CRYPTOPP_ASSERT(size <= 0xffff);
OutputString(block, size);
m_inQueue.Skip(size);
@@ -562,7 +562,7 @@ bool Inflator::DecodeBody()
}
break;
default:
- assert(0);
+ CRYPTOPP_ASSERT(0);
}
}
if (blockEnd)
@@ -591,7 +591,7 @@ void Inflator::FlushOutput()
{
if (m_state != PRE_STREAM)
{
- assert(m_current >= m_lastFlush);
+ CRYPTOPP_ASSERT(m_current >= m_lastFlush);
ProcessDecompressedData(m_window + m_lastFlush, m_current - m_lastFlush);
m_lastFlush = m_current;
}