From a6af94a76f6be06a0829137169bd30c2e17125c4 Mon Sep 17 00:00:00 2001 From: Ignotus Peverell Date: Fri, 13 Jul 2018 19:38:12 +0100 Subject: [PATCH] Validate compact block header before hydrating --- servers/src/common/adapters.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/servers/src/common/adapters.rs b/servers/src/common/adapters.rs index 6713aec19..046e85e7c 100644 --- a/servers/src/common/adapters.rs +++ b/servers/src/common/adapters.rs @@ -119,7 +119,12 @@ impl p2p::ChainAdapter for NetToChainAdapter { // push the freshly hydrated block through the chain pipeline self.process_block(block, addr) } else { - // TODO - do we need to validate the header here? + + // check at least the header is valid before hydrating + if let Err(e) = w(&self.chain).process_block_header(&cb.header, self.chain_opts()) { + debug!(LOGGER, "Invalid compact block header {}: {}", cb.hash(), e); + return !e.is_bad_data(); + } let txs = { let tx_pool = self.tx_pool.read().unwrap();