eip2718: protect against malformed rlp in tx sequence decoder

This commit is contained in:
jangko 2021-05-16 19:15:48 +07:00
parent ef49a6f50a
commit d0eb2de328
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
1 changed files with 3 additions and 0 deletions

View File

@ -379,6 +379,9 @@ proc read*(rlp: var Rlp, T: type Transaction): T =
proc read*(rlp: var Rlp, t: var EthBlock, _: type seq[Transaction]): seq[Transaction] {.inline.} = proc read*(rlp: var Rlp, t: var EthBlock, _: type seq[Transaction]): seq[Transaction] {.inline.} =
# EIP 2718/2930: we have to override this field # EIP 2718/2930: we have to override this field
# for reasons described below in `append` proc # for reasons described below in `append` proc
if not rlp.isList:
raise newException(MalformedRlpError,
"List expected, but got blob.")
for tx in rlp: for tx in rlp:
if tx.isList: if tx.isList:
result.add tx.read(Transaction) result.add tx.read(Transaction)