Skip to content
This repository has been archived by the owner on Feb 18, 2025. It is now read-only.

Commit

Permalink
accounts/abi: return error on fixed bytes with size larger than 32 by…
Browse files Browse the repository at this point in the history
…tes (#26075) (#677)

commit ethereum/go-ethereum@8578eb2.

* fixed bytes with size larger than 32 bytes is not allowed

* add testcase

Reported-by: eugenioclrc <[email protected]>
Co-authored-by: zhiqiangxu <[email protected]>
  • Loading branch information
minh-bq and zhiqiangxu authored Feb 13, 2025
1 parent 3d30c05 commit 08ef4d1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions accounts/abi/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ func NewType(t string, internalType string, components []ArgumentMarshaling) (ty
if varSize == 0 {
typ.T = BytesTy
} else {
if varSize > 32 {
return Type{}, fmt.Errorf("unsupported arg type: %s", t)
}
typ.T = FixedBytesTy
typ.Size = varSize
}
Expand Down
7 changes: 7 additions & 0 deletions accounts/abi/type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,3 +366,10 @@ func TestGetTypeSize(t *testing.T) {
}
}
}

func TestNewFixedBytesOver32(t *testing.T) {
_, err := NewType("bytes4096", "", nil)
if err == nil {
t.Errorf("fixed bytes with size over 32 is not spec'd")
}
}

0 comments on commit 08ef4d1

Please sign in to comment.