From d6bb9ecc6fe618840417df45f750dfb584cb549e Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Mon, 11 Mar 2019 23:36:17 +0000 Subject: [PATCH] serialization: fail on read_varint error --- src/serialization/binary_archive.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/serialization/binary_archive.h b/src/serialization/binary_archive.h index a0e4eff9d..9f60cf311 100644 --- a/src/serialization/binary_archive.h +++ b/src/serialization/binary_archive.h @@ -146,7 +146,8 @@ struct binary_archive : public binary_archive_base void serialize_uvarint(T &v) { typedef std::istreambuf_iterator it; - tools::read_varint(it(stream_), it(), v); // XXX handle failure + if (tools::read_varint(it(stream_), it(), v) < 0) + stream_.setstate(std::ios_base::failbit); } void begin_array(size_t &s)