diff --git a/llarp/router_contact.cpp b/llarp/router_contact.cpp index 33f88ac30..f31705900 100644 --- a/llarp/router_contact.cpp +++ b/llarp/router_contact.cpp @@ -266,8 +266,12 @@ namespace llarp bool RouterContact::DecodeVersion_0(llarp_buffer_t* buf) { - signed_bt_dict = std::string(reinterpret_cast(buf->cur), buf->size_left()); - return bencode_decode_dict(*this, buf); + auto begin = reinterpret_cast(buf->cur); + if (not bencode_decode_dict(*this, buf)) + return false; + auto end = reinterpret_cast(buf->cur); + signed_bt_dict = std::string(begin, std::distance(begin, end)); + return true; } bool