From a3362859222d24ef60cfe9b5b8e5a2a249ee3558 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Fri, 27 Sep 2019 19:48:12 +0300 Subject: [PATCH] Fix a potential OOB error in SSZ deserialization --- beacon_chain/ssz/bytes_reader.nim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/beacon_chain/ssz/bytes_reader.nim b/beacon_chain/ssz/bytes_reader.nim index f4cb9d14b..0fc107e58 100644 --- a/beacon_chain/ssz/bytes_reader.nim +++ b/beacon_chain/ssz/bytes_reader.nim @@ -80,7 +80,8 @@ proc readSszValue*(input: openarray[byte], T: type): T = type ElemType = type result[0] when ElemType is byte|char: result.setLen input.len - copyMem(addr result[0], unsafeAddr input[0], input.len) + if input.len > 0: + copyMem(addr result[0], unsafeAddr input[0], input.len) elif isFixedSize(ElemType): const elemSize = fixedPortionSize(ElemType)