Skip to content

Commit 8a41279

Browse files
committed
Guard against requesting a set of header blocks out of order.
1 parent 8808472 commit 8a41279

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/protocols/protocol_block_in.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,15 @@ bool protocol_block_in::handle_receive_headers(const code& ec,
202202
if (stopped(ec))
203203
return false;
204204

205+
// We don't want to request a batch of headers out of order.
206+
if (!message->is_sequential())
207+
{
208+
LOG_WARNING(LOG_NODE)
209+
<< "Block headers out of order from [" << authority() << "].";
210+
stop(error::channel_stopped);
211+
return false;
212+
}
213+
205214
// There is no benefit to this use of headers, in fact it is suboptimal.
206215
// In v3 headers will be used to build block tree before getting blocks.
207216
const auto response = std::make_shared<get_data>();

0 commit comments

Comments
 (0)