Fix a potential OOB error in SSZ deserialization

This commit is contained in:
Zahary Karadjov 2019-09-27 19:48:12 +03:00 committed by zah
parent c39d4f1817
commit a336285922
1 changed files with 2 additions and 1 deletions

View File

@ -80,6 +80,7 @@ proc readSszValue*(input: openarray[byte], T: type): T =
type ElemType = type result[0] type ElemType = type result[0]
when ElemType is byte|char: when ElemType is byte|char:
result.setLen input.len result.setLen input.len
if input.len > 0:
copyMem(addr result[0], unsafeAddr input[0], input.len) copyMem(addr result[0], unsafeAddr input[0], input.len)
elif isFixedSize(ElemType): elif isFixedSize(ElemType):