diff options
author | Wladimir J. van der Laan <laanwj@protonmail.com> | 2020-11-20 06:05:42 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@protonmail.com> | 2020-11-20 06:10:58 +0100 |
commit | fdd068507d2694137d72638d87ea961e6f16a753 (patch) | |
tree | 30d062132e86047b71d7de2ff0c021ca3d8aea82 /src/test/fuzz/p2p_transport_deserializer.cpp | |
parent | 46f0b2f97601e9d13277fd73bed9b0219bcdee5b (diff) | |
parent | fa5ed3b4ca609426b2622cad235e107d33db7b30 (diff) | |
download | bitcoin-fdd068507d2694137d72638d87ea961e6f16a753.tar.xz |
Merge #20056: net: Use Span in ReceiveMsgBytes
fa5ed3b4ca609426b2622cad235e107d33db7b30 net: Use Span in ReceiveMsgBytes (MarcoFalke)
Pull request description:
Pass a data pointer and a size as span in `ReceiveMsgBytes` to get the benefits of a span
ACKs for top commit:
jonatack:
ACK fa5ed3b4ca609426b2622cad235e107d33db7b30 code review, rebased to current master 12a1c3ad1a43634, debug build, unit tests, ran bitcoind/-netinfo/getpeerinfo
theStack:
ACK fa5ed3b4ca609426b2622cad235e107d33db7b30
Tree-SHA512: 89bf111323148d6e6e50185ad20ab39f73ab3a58a27e46319e3a08bcf5dcf9d6aa84faff0fd6afb90cb892ac2f557a237c144560986063bc736a69ace353ab9d
Diffstat (limited to 'src/test/fuzz/p2p_transport_deserializer.cpp')
-rw-r--r-- | src/test/fuzz/p2p_transport_deserializer.cpp | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/test/fuzz/p2p_transport_deserializer.cpp b/src/test/fuzz/p2p_transport_deserializer.cpp index 7e216e16fe..3feabcc99a 100644 --- a/src/test/fuzz/p2p_transport_deserializer.cpp +++ b/src/test/fuzz/p2p_transport_deserializer.cpp @@ -21,15 +21,12 @@ void test_one_input(const std::vector<uint8_t>& buffer) { // Construct deserializer, with a dummy NodeId V1TransportDeserializer deserializer{Params(), (NodeId)0, SER_NETWORK, INIT_PROTO_VERSION}; - const char* pch = (const char*)buffer.data(); - size_t n_bytes = buffer.size(); - while (n_bytes > 0) { - const int handled = deserializer.Read(pch, n_bytes); + Span<const char> msg_bytes{(const char*)buffer.data(), buffer.size()}; + while (msg_bytes.size() > 0) { + const int handled = deserializer.Read(msg_bytes); if (handled < 0) { break; } - pch += handled; - n_bytes -= handled; if (deserializer.Complete()) { const std::chrono::microseconds m_time{std::numeric_limits<int64_t>::max()}; uint32_t out_err_raw_size{0}; |