From f7a4c40c50f544191339b358e7418e72b0134fe4 Mon Sep 17 00:00:00 2001 From: Thomas Arts Date: Wed, 29 May 2019 08:21:25 +0200 Subject: [PATCH] Only decode correctly encoded negative binaries --- src/aeb_fate_encoding.erl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/aeb_fate_encoding.erl b/src/aeb_fate_encoding.erl index 1a73809..22603b2 100644 --- a/src/aeb_fate_encoding.erl +++ b/src/aeb_fate_encoding.erl @@ -318,7 +318,12 @@ deserialize2(<>) -> Rest2}; deserialize2(<>) -> {Bint, Rest2} = aeser_rlp:decode_one(Rest), - {?FATE_BITS(-binary:decode_unsigned(Bint)), Rest2}; + case binary:decode_unsigned(Bint) of + Pos when Pos > 0 -> + {?FATE_BITS(-Pos), Rest2}; + N -> + error({illegal_parameter, neg_bits, N}) + end; deserialize2(<>) -> {Bint, Rest2} = aeser_rlp:decode_one(Rest), {?FATE_BITS(binary:decode_unsigned(Bint)), Rest2};