diff --git a/src/protocols/protocol_filter_out_70015.cpp b/src/protocols/protocol_filter_out_70015.cpp index 46a16d9f..cb08fcfb 100644 --- a/src/protocols/protocol_filter_out_70015.cpp +++ b/src/protocols/protocol_filter_out_70015.cpp @@ -141,8 +141,8 @@ bool protocol_filter_out_70015::handle_receive_get_filter_headers( } // bip157: difference [stop_height - start_height] MUST be less than 2000. - const auto count = subtract(stop_height, start_height); - if (count >= max_client_filter_headers) + const auto count = add1(subtract(stop_height, start_height)); + if (count > max_client_filter_headers) { stop(network::error::protocol_violation); return false; @@ -205,8 +205,8 @@ bool protocol_filter_out_70015::handle_receive_get_filters(const code& ec, } // bip157: difference [stop_height - start_height] MUST be less than 1000. - const auto count = subtract(stop_height, start_height); - if (count >= max_client_filters) + const auto count = add1(subtract(stop_height, start_height)); + if (count > max_client_filters) { stop(network::error::protocol_violation); return false; diff --git a/test/protocols/protocol.cpp b/test/protocols/protocol.cpp index 15f54ee7..1fcb6a8b 100644 --- a/test/protocols/protocol.cpp +++ b/test/protocols/protocol.cpp @@ -640,6 +640,9 @@ BOOST_AUTO_TEST_CASE(protocol_filter_out_70015__get_client_filters__unfiltered_s send(get_client_filters{ client_filter::type_id::neutrino, 0, descendant(1).hash() }, node_version->value); + const auto message = client_filter::deserialize(node_version->value, receive(client_filter::command)); + BOOST_REQUIRE(message); + BOOST_REQUIRE(message->block_hash == config_.bitcoin.genesis_block.hash()); BOOST_REQUIRE_THROW(receive(client_filter::command), boost::system::system_error); }