From 7432805b6aae638bf4378e10ee2fb9511ca41800 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 25 May 2016 20:03:13 +0100 Subject: [PATCH] Fix special RLP case for length=1 firstbyte=0 --- firmware/ethereum.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/firmware/ethereum.c b/firmware/ethereum.c index 5e554c67d1..6baf2cbd9c 100644 --- a/firmware/ethereum.c +++ b/firmware/ethereum.c @@ -43,7 +43,8 @@ struct SHA3_CTX keccak_ctx; static int rlp_encode_length(uint8_t *buf, int length, uint8_t firstbyte, bool list) { if (!list && (length == 1 && firstbyte <= 0x7f)) { - buf[0] = firstbyte; + /* Extra-special case: null is encoded differently */ + buf[0] = !firstbyte ? 0x80 : firstbyte; return 1; } else if (length <= 55) { buf[0] = (list ? 0xc0 : 0x80) + length;