Duh! This is the right fix for the bug Jed reported.

This commit is contained in:
JoelKatz
2012-06-30 18:59:38 -07:00
parent 30d76c87a3
commit c90f834f7f

View File

@@ -247,7 +247,10 @@ SHAMapTreeNode::SHAMapTreeNode(const SHAMapNode& id, const std::vector<unsigned
if (format == STN_ARF_PREFIXED)
{
if (rawNode.size() < 4)
{
Log(lsINFO) << "size < 4";
throw std::runtime_error("invalid P node");
}
uint32 prefix = rawNode[0]; prefix <<= 8; prefix |= rawNode[1]; prefix <<= 8;
prefix |= rawNode[2]; prefix <<= 8; prefix |= rawNode[3];
@@ -258,17 +261,20 @@ SHAMapTreeNode::SHAMapTreeNode(const SHAMapNode& id, const std::vector<unsigned
mItem = boost::make_shared<SHAMapItem>(s.getSHA512Half(), s.peekData());
mType = tnTRANSACTION;
}
if (prefix == sHP_LeafNode)
else if (prefix == sHP_LeafNode)
{
uint256 u;
s.get256(u, s.getLength() - 32);
s.chop(32);
if (u.isZero())
{
Log(lsINFO) << "invalid PLN node";
throw std::runtime_error("invalid PLN node");
}
mItem = boost::make_shared<SHAMapItem>(u, s.peekData());
mType = tnACCOUNT_STATE;
}
if (prefix == sHP_InnerNode)
else if (prefix == sHP_InnerNode)
{
if (rawNode.size() != (512 + 4))
throw std::runtime_error("invalid PIN node");
@@ -277,7 +283,10 @@ SHAMapTreeNode::SHAMapTreeNode(const SHAMapNode& id, const std::vector<unsigned
mType = tnINNER;
}
else
{
Log(lsINFO) << "Unknown node prefix " << std::hex << prefix << std::dec;
throw std::runtime_error("invalid node prefix");
}
}
updateHash();