Skip to content

Commit 8578eb2

Browse files
authored
accounts/abi: return error on fixed bytes with size larger than 32 bytes (#26075)
* fixed bytes with size larger than 32 bytes is not allowed * add testcase
1 parent 0c40df5 commit 8578eb2

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
@@ -154,6 +154,9 @@ func NewType(t string, internalType string, components []ArgumentMarshaling) (ty
154154
if varSize == 0 {
155155
typ.T = BytesTy
156156
} else {
157+
if varSize > 32 {
158+
return Type{}, fmt.Errorf("unsupported arg type: %s", t)
159+
}
157160
typ.T = FixedBytesTy
158161
typ.Size = varSize
159162
}

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)