From a439fbf63e3402b3b37e80aa7248becb3f707d48 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 20 May 2017 23:01:56 +0200 Subject: [PATCH] fixed bug (due to new serializer) that caused a wrong hash to be computed when sending distant messages --- libretroshare/src/grouter/p3grouter.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libretroshare/src/grouter/p3grouter.cc b/libretroshare/src/grouter/p3grouter.cc index d77903df8..1bcf83d3f 100644 --- a/libretroshare/src/grouter/p3grouter.cc +++ b/libretroshare/src/grouter/p3grouter.cc @@ -1624,11 +1624,18 @@ Sha1CheckSum p3GRouter::computeDataItemHash(RsGRouterGenericDataItem *data_item) RsTemporaryMemory mem(total_size) ; uint32_t offset = 0 ; - signature_serializer.serialise(data_item,mem,&total_size) ; - offset += signed_data_size ; + uint32_t tmp_size = total_size ; + signature_serializer.serialise(data_item,mem,&tmp_size) ; + if(tmp_size != signed_data_size) + std::cerr << "(EE) Some error occured in p3GRouter::computeDataItemHash(). Mismatched offset/data size" << std::endl; + + offset += tmp_size ; data_item->signature.SetTlv(mem, total_size,&offset) ; + if(offset != total_size) + std::cerr << "(EE) Some error occured in p3GRouter::computeDataItemHash(). Mismatched offset/data size" << std::endl; + return RsDirUtil::sha1sum(mem,total_size) ; }