From c04cbfe34f5acd214d9c729b90884ac774146870 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Fri, 2 Oct 2020 11:09:38 -0400 Subject: [PATCH] fix decode version 0 rc when in version 1 mode --- llarp/router_contact.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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