Browse Source

first zeros in rlp

m_data overflow percautions
cl-refactor
winsvega 10 years ago
parent
commit
e1caebe331
  1. 10
      libdevcore/RLP.cpp

10
libdevcore/RLP.cpp

@ -149,7 +149,10 @@ unsigned RLP::length() const
return n - c_rlpDataImmLenStart;
else if (n < c_rlpListStart)
{
if ((int)m_data.size() <= n - c_rlpDataIndLenZero || m_data[1] == 0)
if ((int)m_data.size() <= n - c_rlpDataIndLenZero)
BOOST_THROW_EXCEPTION(BadRLP());
if ((int)m_data.size() > 1)
if (m_data[1] == 0)
BOOST_THROW_EXCEPTION(BadRLP());
for (int i = 0; i < n - c_rlpDataIndLenZero; ++i)
ret = (ret << 8) | m_data[i + 1];
@ -158,7 +161,10 @@ unsigned RLP::length() const
return n - c_rlpListStart;
else
{
if ((int)m_data.size() <= n - c_rlpListIndLenZero || m_data[1] == 0)
if ((int)m_data.size() <= n - c_rlpListIndLenZero)
BOOST_THROW_EXCEPTION(BadRLP());
if ((int)m_data.size() > 1)
if (m_data[1] == 0)
BOOST_THROW_EXCEPTION(BadRLP());
for (int i = 0; i < n - c_rlpListIndLenZero; ++i)
ret = (ret << 8) | m_data[i + 1];

Loading…
Cancel
Save