harden SSZ reader

This commit is contained in:
Dustin Brody 2020-04-16 21:21:28 +02:00 committed by zah
parent 8b6c51e78d
commit 71e802c740
1 changed files with 2 additions and 0 deletions

View File

@ -169,6 +169,8 @@ func readSszValue*(input: openarray[byte], T: type): T =
raise newException(MalformedSszError, "SSZ field offsets are not monotonically increasing") raise newException(MalformedSszError, "SSZ field offsets are not monotonically increasing")
elif endOffset > input.len: elif endOffset > input.len:
raise newException(MalformedSszError, "SSZ field offset points past the end of the input") raise newException(MalformedSszError, "SSZ field offset points past the end of the input")
elif startOffset < boundingOffsets[0]:
raise newException(MalformedSszError, "SSZ field offset points outside bounding offsets")
# TODO The extra type escaping here is a work-around for a Nim issue: # TODO The extra type escaping here is a work-around for a Nim issue:
when type(FieldType) is type(SszType): when type(FieldType) is type(SszType):