Tidy up SHAMap node handling of invalid wire formats

This commit is contained in:
JoelKatz
2015-06-17 13:31:02 -07:00
committed by Vinnie Falco
parent 2d6af1da1d
commit 749f31f69d
4 changed files with 23 additions and 30 deletions

View File

@@ -79,28 +79,14 @@ SHAMapAbstractNode::make(Blob const& rawNode, std::uint32_t seq, SHANodeFormat f
if (format == snfWIRE)
{
if (rawNode.empty ())
{
#ifdef BEAST_DEBUG
deprecatedLogs().journal("SHAMapTreeNode").fatal <<
"Wire format node is empty";
assert (false);
#endif
throw std::runtime_error ("invalid node AW type");
}
return {};
Serializer s (rawNode.data(), rawNode.size() - 1);
int type = rawNode.back ();
int len = s.getLength ();
if ((type < 0) || (type > 4))
{
#ifdef BEAST_DEBUG
deprecatedLogs().journal("SHAMapTreeNode").fatal <<
"Invalid wire format node" << strHex (rawNode);
assert (false);
#endif
throw std::runtime_error ("invalid node AW type");
}
return {};
if (type == 0)
{