From bb8e57e426884dc83853b2ad2b3765dcea331fc6 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Thu, 26 Feb 2015 14:44:29 +0100 Subject: [PATCH 1/2] block and tx RLP needs to be a list --- libethcore/BlockInfo.cpp | 2 +- libethereum/BlockChain.cpp | 5 +++++ libethereum/Transaction.cpp | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index fec010c2d..ce158c3cc 100644 --- a/libethcore/BlockInfo.cpp +++ b/libethcore/BlockInfo.cpp @@ -134,7 +134,7 @@ void BlockInfo::populate(bytesConstRef _block, bool _checkNonce) RLP header = root[0]; if (!header.isList()) - BOOST_THROW_EXCEPTION(InvalidBlockFormat(0,header.data()) << errinfo_comment("block header needs to be a list")); + BOOST_THROW_EXCEPTION(InvalidBlockFormat(0, header.data()) << errinfo_comment("block header needs to be a list")); populateFromHeader(header, _checkNonce); if (!root[1].isList()) diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index 29095076f..293a9d757 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -209,6 +209,11 @@ h256s BlockChain::import(bytes const& _block, OverlayDB const& _db) try #endif { + RLP blockRLP(_block); + + if (!blockRLP.isList()) + BOOST_THROW_EXCEPTION(InvalidBlockFormat(0,blockRLP.data()) << errinfo_comment("block header needs to be a list")); + bi.populate(&_block); bi.verifyInternals(&_block); } diff --git a/libethereum/Transaction.cpp b/libethereum/Transaction.cpp index 96689326d..a89083648 100644 --- a/libethereum/Transaction.cpp +++ b/libethereum/Transaction.cpp @@ -36,6 +36,9 @@ Transaction::Transaction(bytesConstRef _rlpData, CheckSignature _checkSig) RLP rlp(_rlpData); try { + if (!rlp.isList()) + BOOST_THROW_EXCEPTION(BadRLP() << errinfo_comment("transaction RLP must be a list")); + m_nonce = rlp[field = 0].toInt(); m_gasPrice = rlp[field = 1].toInt(); m_gas = rlp[field = 2].toInt(); From e5ce6fb0d92172dfb29731add3ee53e18359f74e Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Thu, 26 Feb 2015 14:45:14 +0100 Subject: [PATCH 2/2] style --- libethereum/BlockChain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index 293a9d757..c7c55758b 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -212,7 +212,7 @@ h256s BlockChain::import(bytes const& _block, OverlayDB const& _db) RLP blockRLP(_block); if (!blockRLP.isList()) - BOOST_THROW_EXCEPTION(InvalidBlockFormat(0,blockRLP.data()) << errinfo_comment("block header needs to be a list")); + BOOST_THROW_EXCEPTION(InvalidBlockFormat(0, blockRLP.data()) << errinfo_comment("block header needs to be a list")); bi.populate(&_block); bi.verifyInternals(&_block);