Skip to content

Commit

Permalink
fix index out of range (DoS) in txn unmarshalling (umbracle#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
shouc authored May 27, 2022
1 parent c1d8327 commit 37ddc01
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions structs_marshal_rlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ func (t *Transaction) MarshalRLPWith(arena *fastrlp.Arena) (*fastrlp.Value, erro
func (t *Transaction) UnmarshalRLP(buf []byte) error {
t.Hash = BytesToHash(Keccak256(buf))

if len(buf) < 1 {
return fmt.Errorf("expecting 1 byte but 0 byte provided")
}
if buf[0] <= 0x7f {
// it includes a type byte
switch typ := buf[0]; typ {
Expand Down

0 comments on commit 37ddc01

Please sign in to comment.