Skip to content

Commit 1908539

Browse files
committed
accounts/abi: return error on fixed bytes with size larger than 32 bytes (ethereum#26075)
* fixed bytes with size larger than 32 bytes is not allowed * add testcase
1 parent 4292979 commit 1908539

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

accounts/abi/type.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ func NewType(t string, internalType string, components []ArgumentMarshaling) (ty
153153
if varSize == 0 {
154154
typ.T = BytesTy
155155
} else {
156+
if varSize > 32 {
157+
return Type{}, fmt.Errorf("unsupported arg type: %s", t)
158+
}
156159
typ.T = FixedBytesTy
157160
typ.Size = varSize
158161
}

accounts/abi/type_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,3 +366,10 @@ func TestGetTypeSize(t *testing.T) {
366366
}
367367
}
368368
}
369+
370+
func TestNewFixedBytesOver32(t *testing.T) {
371+
_, err := NewType("bytes4096", "", nil)
372+
if err == nil {
373+
t.Errorf("fixed bytes with size over 32 is not spec'd")
374+
}
375+
}

0 commit comments

Comments
 (0)