mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
core/types: fix problem decoding short typed tx
If kind == rlp.Byte, the size reported by Stream.Kind will be zero, but we need a buffer of size 1 for ReadBytes. Since typed txs always have to be longer than 1 byte, we can just return an error for kind == rlp.Byte.
This commit is contained in:
parent
c84ffe7d0f
commit
b3f9f7b337
2 changed files with 4 additions and 0 deletions
|
|
@ -165,6 +165,8 @@ func (r *Receipt) DecodeRLP(s *rlp.Stream) error {
|
|||
}
|
||||
r.Type = LegacyTxType
|
||||
return r.setFromRLP(dec)
|
||||
case kind == rlp.Byte:
|
||||
return errShortTypedReceipt
|
||||
default:
|
||||
// It's an EIP-2718 typed tx receipt.
|
||||
b, buf, err := getPooledBuffer(size)
|
||||
|
|
|
|||
|
|
@ -145,6 +145,8 @@ func (tx *Transaction) DecodeRLP(s *rlp.Stream) error {
|
|||
tx.setDecoded(&inner, rlp.ListSize(size))
|
||||
}
|
||||
return err
|
||||
case kind == rlp.Byte:
|
||||
return errShortTypedTx
|
||||
default:
|
||||
// It's an EIP-2718 typed TX envelope.
|
||||
// First read the tx payload bytes into a temporary buffer.
|
||||
|
|
|
|||
Loading…
Reference in a new issue