From a47eec14e4e7b479f3b3f19a61fa82161441f9b0 Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Wed, 10 Oct 2018 21:54:50 +0200 Subject: [PATCH] Print a warning if deserialized rstime_t is negative --- libretroshare/src/serialiser/rsbaseserial.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libretroshare/src/serialiser/rsbaseserial.cc b/libretroshare/src/serialiser/rsbaseserial.cc index 58dadcdb3..968ee877d 100644 --- a/libretroshare/src/serialiser/rsbaseserial.cc +++ b/libretroshare/src/serialiser/rsbaseserial.cc @@ -26,8 +26,10 @@ #include "retroshare/rstypes.h" #include "serialiser/rsbaseserial.h" #include "util/rsnet.h" +#include "util/rstime.h" #include +#include /* UInt8 get/set */ @@ -289,11 +291,15 @@ bool setRawString(void *data, uint32_t size, uint32_t *offset, const std::string bool getRawTimeT(const void *data,uint32_t size,uint32_t *offset,rstime_t& t) { - uint64_t T ; - bool res = getRawUInt64(data,size,offset,&T) ; - t = T ; + uint64_t T; + bool res = getRawUInt64(data,size,offset,&T); + t = T; - return res ; + if(t < 0) // [[unlikely]] + std::cerr << __PRETTY_FUNCTION__ << " got a negative time: " << t + << " this seems fishy, report to the developers!" << std::endl; + + return res; } bool setRawTimeT(void *data, uint32_t size, uint32_t *offset, const rstime_t& t) {